I have not used this in a while, but it uses the array approach and it worked once, it should get you started:
// where $input is the user input:
$profan = array("take","your","pick");
$blurb = "badword";
$cnt = count($profan);
if ( $cnt > 0 ){
$a=0;
while($a<$cnt){
$sWord = $profan[$a];
if(strstr(strtoupper($input), strtoupper($sWord))){
if(strtoupper($input)==strtoupper($sWord)) $input=$blurb;
$input = eregi_replace("^$sWord([^a-zA-Z])", "$blurb\\1", $input);
$input = eregi_replace("([^a-zA-Z])$sWord$", "\\1$blurb", $input);
while(eregi("([^a-zA-Z])($sWord)([^a-zA-Z])", $input)){
$input = eregi_replace("([^a-zA-Z])($sWord)([^a-zA-Z])", "\\1$blurb\\3", $input);
}
}
$a++;
}
}
--ph