I don't know that there's really an easy way to do this. You could easily use [man]strcmp[/man] or [man]strncmp[/man] to tell if the string has been changed (as long as you save the new string to a new variable):
$string = 'This has some bad words darn, cuss, bite which will be replaced by said filtering.';
$filter = array('darn','cuss','bite');
$replace = '--blam!--';
$newString = str_replace($filter, $replace, $string);
if(strcmp($string, $newString) != 0)
echo 'Words have been changed!!!';
As for counting what's changed, you'd probably want to split each sentence up by spaces, thus chunking it by words. Then use a [man]for[/man] loop to loop through all the words and figure out which ones changed. Continuing from the previous example:
if(strcmp($string, $newString) != 0)
{
$S_words = explode(" ", $string);
$n_words = explode(" ", $newString);
if(count($S_words) > count($n_words))
{
$left = $S_words;
$right = $n_words;
$count = count($S_words);
}
else
{
$left = $n_words;
$right = $S_words;
$count = count($n_words);
}
$changed = 0;
for($i=0; $i<$count; $i++)
{
if(strcmp($left[$i], $right[$i]) == 0)
continue;
echo 'The word in spot #' . $i . ' was changed.<br />';
$changed++;
}
echo 'There were a total of ' . $changed . ' changed words.';
}
Not simple, but it does its job.