如何過濾phrase
使用php?任何人都可以給我一個函數調用?php過濾短語
例如,如果我想這個「從一個句子There are no user contributed notes for this page.
所以過濾那句「不」」這句話就像回報感謝There are user contributed notes for page.
。
<?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`
?>
很大,非常感謝許多。 –