Answers for "php in_array substring"

PHP
0

php find part of string in array

foreach($array as $item){
  if(strpos($item,"mysearchword")!== false){
    echo 'found';
  }
}
Posted by: Guest on May-05-2021
1

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';
}
Posted by: Guest on October-04-2021

Browse Popular Code Answers by Language