Like I have 'badword1' listed but the user can input 'BADWORD1' or 'bAdwOrd1' and bypass it. How can I make the below code case insensitive?
/* REPLACE BAD WORDS WITH ASTERISKS */
Code: Select all
function word_filter($str)
{
$bad_words=array(
"badword1","badword2","badword3","badword4"
);
$replacements=array(
"**********"
);
for($i=0;$i < sizeof($bad_words);$i++){
srand((double)microtime()*1000000);
$rand_key = (rand()%sizeof($replacements));
$str=eregi_replace($bad_words[$i], $replacements[$rand_key], $str);
}
return $str;
}