I'm trying to find a needle in a "haystack" using preg_match() given that the haystack is an array of items x, y, z.
The snippet is like this:
$gethay=mysql_query("SELECT * FROM table");
$haystack=mysql_fetch_array($gethay);
preg_match('/\b' . preg_quote($haystack['element']) . '\b/i', $needle);
If the haystack contains "apple", "plum", "orange" and I'm looking for "plum" preg_match() won't find it unless it's the last element of the array (i.e. I delete item "orange").
Does anyone know a solution to overcome this?
Thanks!!!