I'm trying to update an older script. None of my preg_replace_callback
variations are working, though. Does anyone know a solution?
This is the original code:
public static function filterHTML($html) {
// a simple preg_replace will do for now to see it actually works
// turn the PA::$config->profanity array into an array of regexp
$profanity = array();
foreach (PA::$config->profanity as $i => $w) {
$profanity[] = "!\b(" . $w . ")\b!ie";
// the \b ensures that we are dealing with szand alone
// occurences of the word or phrase
// /ie case insensitive and run replacement as code
}
$repl_code = "ProfanityFilter::replace('$1')";
return (preg_replace($profanity, $repl_code, $html));
}