Forum Moderators: coopster
$keywords = preg_split("/[,¦OR]/", $keywords);
What I want it to do is split the string on , ¦ or OR. It does that but it will also split on O or R. Can someone point me in the right direction?
I also need to find the element(s) of that array that start and end with a quote. Each element of the array can consist of any combination of letters (and numbers) and spaces. I assume I need to use preg_match("/^\"[A-z0-9]*\"$/", $keywords[$i]) or something similar where $i is a number but I can't seem to get it to match.
$keywords = preg_split("/(,¦OR¦\¦)/", $keywords);
I also need to find the element(s) of that array that start and end with a quote.
foreach ($keywords as $value) if (preg_match("/^\".*\"$/", $value)) print $value;
Now to try and work out how to determine if an element of the array starts and ends with double quotes. One day I will try to learn regular expressions properly.
$keywords = preg_split("/(,¦\s+OR\s+¦\¦)/", $keywords);
One day I will try to learn regular expressions properly.
Hey, so will I ;)
A B "C D" E
into four elements: "A"; "B"; "C D"; "E"
$keywords = 'A B "C D" E';
preg_match_all("/\".*\"¦\b\S+\b/U", $keywords, $matches);
print "<pre>"; print_r($matches); exit("</pre>");