The following script will take your variable $comments and filter out any bad words. eregi_replace is case-insensitive, so it will take out the word, no matter the way it is input.
$bad_words = explode('|', 'badword1|badword2|badword3|etc|etc');
foreach ($bad_words as $naughty)
{
$comments = eregi_replace($naughty, "#!@%*#", $comments);
}
This will turn the input "I really think that you are a badword1, and a badword2"
into
"I really think that you are a #!@%*#, and a #!@%*#"
It will at least help keep a message board or guestbook clean.