Quote:
Originally Posted by m002.p
Thanks.
So finally, is it best to use the ". instead of {} for variables directly in the preg_match function to avoid the {} being used as part of the search critera?
|
Well, no. It was my mistake - the {} was necessary around the variable name in your original string, and would really be part of the variable name and not part of the pattern, so that was OK. The only issue is that you have to put the variable through preg_quote() unless you're sure it won't contain any meta-characters (unless the variable actually contained a pattern, of course). You could instead do this if you prefered:
Code:
$console['chat'] = preg_quote($console['chat'], '/');
if (preg_match("/\b{$console['chat']}\b/", 'BOT call'))