function filterBadWords($str){
// words to filter
$badwords=array( "[naughty word removed]", "[naughty word removed]", "[no swearing please]", "[oops]", "[oops]", "[naughty word removed]", "[oops]", "[oops]" );
// replace filtered words with
$replacements=array( "[naughty word removed]", "[how wude!]", "[no swearing please]" );
for($i=0;$i < sizeof($badwords);$i++){
srand((double)microtime()*1000000);
$rand_key = (rand()%sizeof($replacements));
$str=eregi_replace($badwords[$i], $replacements[$rand_key], $str);
}
return $str;
}
- http://www.gr0w.com/articles/code/php_bad_words_filter/
- google