This is for a chat page. I have a $string = \"This dude is a mothertrucker\". I have an array of badwords: $bads = array(\'truck\', \'shot\', etc)
$string = \"This dude is a mothertrucker\"
$bads = array(\'truck\', \'shot\', etc)
You can do the filter this way also
$string = "This dude is a mothertrucker"; if (preg_match_all('#\b(truck|shot|etc)\b#', $string )) //add all bad words here. { echo "There is a bad word in the string"; } else { echo "There is no bad word in the string"; }