i try to strip a typical Google Search String into it’s part.
i.e. the sting could be :”how to” engine -fuel
So i want to get “how to” and engine and -fuel seperately.
I tried with the following preg_match_all, but i get “how and to” seperately as well and that might get unneccesarily difficult to process.
preg_match_all(
'=(["]{1}[^"]{1,}["]{1})'
.'|([-]{1}[^ ]{1,}[ ]{1})'
.'|([^-"]{1}[^ ]{1,}[ ]{1})=si',
$filter,
$matches,
PREG_PATTERN_ORDER);
Anyone any idea how to do this right?
Try:
which will print:
Array ( [0] => Array ( [0] => "how to" [1] => engine [2] => -fuel ) )Meaning: