Using the strpos function:
<?php
$array_bad_words = Array ("bad word",
"offenceive words",
"php",
"naughty word");
$string = "This string contains bad words. The use of offenceive words is prohibitted in PHP this script.
Only naughty words can describe the inconvenience this causes.";
for ($x = 0; $x < sizeof($array_bad_words); $x++) {
if (strpos (strtolower($string), $array_bad_words[$x]) !== false)
echo ( "bad words found");
}
?>
This will pick up occurences of each word contained in the array. It might also be a good idea to load these words into an array from a database. This makes adding new words easier.