Try using str_ireplace, it is str_replace but is case insensitive.
str_replace and str_ireplace both can take arrays as parameters for the
needle, replacement value. The string functions tend to be much faster
than regular expressions, in any case you don't need the foreach..
Jason
Chris
Was able to get this to filter:
.
?
}
$guestbook = stripslashes($message);
$this_is_the_message=$guestbook;
$dirty_words = array(badword1,badword2,badword3);
$message = $this_is_the_message;
foreach ($dirty_words as $word){
$message = str_replace($word, , $message);
}
// example #1: in the script the text in the variable $guestbook does not
get replaced.
?
$dirty_words = array(badword1,badword2,badword3);
$guestbook = stripslashes($message);
foreach ($dirty_words as $word){
$message = str_replace($word, , $guestbook);
}
echo $message;
?
3 matches
Mail list logo