That is actually a PHP 5 function:
str_ireplace()
You are probably running PHP 4.x.x
One way to get around this problem is to make the strings all lowercase (strtolower()) and then run str_replace().
Only problem is if someone types:
I am the model of a Modern Major General
and you want to censor model, you would get this as the output:
i am the very ###*# of a modern major general
In which case, you could use ucfirst() to uppercase the first letter of each word:
I Am The Very ###*# Of A Modern Major General
Or, you could try using eregi_replace() and see if that works. Only problem there is eregi_replace doesn't use arrays to replace, so you'd have to loop through it:
$input_text = "This is the text to search through";
//a string which is improbable to be in an input text
$delimiter="*#*#*#*";
//array of bad words and phrases
$bad_words = array("word1", "phrase with spaces 1");
//replace all occurences of bad words
$new_string = ''; // Empty the string for future use
foreach($bad_words as $word)
{
$new_string .= eregi_replace($word, $delimeter, $input_text);
}
//split string by delimiter
$arr = explode($delimiter, $new_string);
$nr_occurences = count($arr) - 1;
if ($nr_occurences > 0) echo "You have used bad words $nr_occurences time(s).";
~Brett