Page 1 of 1

preg_match_all php variable

Posted: Fri May 12, 2006 9:05 pm
by iWuha
Hi,

I'm trying to search for a particular word in a string by doing :

Code: Select all

preg_match_all("/\b" . $result2['terms'] .  "\b/i", $cont, $words);
However, I'm getting this warning:

Code: Select all

warning: preg_match_all(): Unknown modifier 'r' in C:\Program Files\Software\Developer\Database\xampp\htdocs\db\includes\common.inc(1150) : eval()'d code on line 54.
Submitted by ausfood on Mon, 05/08/2006 - 22:52.
Keyword : ground are found 1 times
Keyword : clear are found 1 times
Keyword : Sarlija are found 5 times
Why is that happening? Any help on this would be appreciated. Thanks! :)

Posted: Sun May 14, 2006 5:17 pm
by feyd
$result2['terms'] has slashes inside it would appear.

Posted: Sun May 14, 2006 6:49 pm
by sweatje
Try

Code: Select all

preg_match_all("/\b" . preg_quote($result2['terms'],'/') .  "\b/i", $cont, $words);