How to filter phrase
use php? Can anyone give me a function call?
for example, If I want filter the phrase 'no' 'this' from a sentence There are no user contributed notes for this page.
So that the sentence return like There are user contributed notes for page.
Thanks.
<?php
function filterBadWords($str)
{
$badwords = array('no','this');
$replacements = " ";
foreach ($badwords AS $badword)
{
$str = eregi_replace($badword, str_repeat(' ', strlen($badword)), $str);
}
return $str;
}
$string = "There are user contributed notes for page.";
print filterBadWords($string); // this will filter `no` from `notes`
?>