1$string = "This dude is a mean mothertrucker";
2$badwords = array('truck', 'shot', 'ass');
3$banstring = ($string != str_ireplace($badwords,"XX",$string))? true: false;
4if ($banstring) {
5 echo 'Bad words found';
6} else {
7 echo 'No bad words in the string';
8}
9