Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php check if string contains words from array

$string = "This dude is a mean mothertrucker";
$badwords = array('truck', 'shot', 'ass');
$banstring = ($string != str_ireplace($badwords,"XX",$string))? true: false;
if ($banstring) {
   echo 'Bad words found';
} else {
    echo 'No bad words in the string';
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #check #string #words #array
ADD COMMENT
Topic
Name
7+8 =