When the input string contains a “/” symbol, I’m getting a PHP error:
Warning: preg_match() [function.preg-match]: Unknown modifier
How can I resolve it?
$token = '/<'.$tag.'[^>]*>(.*\b'.$keyword.'\b.*)<\/'.$tag.'>/siU';
if(preg_match($token, &$content, $matches))
{
$match = 1;
}
return $match;
You should use
preg_quote()to escape tag and keyword, like this: