I need to check if a string contains a particular words.
My code is the following:
// Get index.html source
$html = file_get_contents('extract/index.html');
// Bad words checker
$badWords = array("iframe", "alert");
$matches = array();
$matchFound = preg_match_all("/\b(" . implode($badWords,"|") . ")\b/i", $html, $matches);
if ($matchFound) {
$words = array_unique($matches[0]);
foreach($words as $word) {
$results[] = array('Error' => "Keyword found : ". $word);
}
}
else {
$results[] = array('Success' => "No keywords found.");
}
Each time I want to execute this, I have the following warning:
Warning: preg_match_all(): Unknown modifier 'w' in /home/public_html/upload.php on line 131
Line 131:
$matchFound = preg_match_all("/\b(" . implode($badWords,"|") . ")\b/i", $html, $matches);
Do you know why ?
Thanks.