PHP Snippet 1:
if(preg_match('(bad|naughty)', $data) === 1) { }
PHP Snippet 2:
if (strpos($data, 'bad || naughty') !== false) {
PHP Snippet 3:
if(preg_match("/(bad|naughty|other)/i", $data)){
//one of these string found
}
PHP Snippet 4:
if(preg_match("/\b(bad|naughty)\b/", $data)){
echo "Found";
}
PHP Snippet 5:
if (strpos($data, 'bad')!==false or strpos($data, 'naughty')!== false) {
echo "Found";
}
PHP Snippet 6:
if (count(array_intersect(explode(' ', $data),array('bad','naugthy')))) {
echo "Found";
}
PHP Snippet 7:
if(preg_match('[bad|naughty]', $data)) { }
PHP Snippet 8:
if (substr_count($data, 'bad') || substr_count($data, 'naughty')){
echo "Found";
}
PHP Snippet 9:
if (strpos($data, 'bad')!==false || strpos($data, 'naughty')!== false) {
echo "Found";
}
PHP Snippet 10:
'bad || naughty'
PHP Snippet 11:
if( $words_in_data ){
echo 'true';
}
PHP Snippet 12:
if (strposMultiple($data, ['bad', 'naughty']) !== false) {
//...
}
PHP Snippet 13:
function strposMultiple($haystack, $needle, $offset = 0) {
if(is_string($needle))
return strpos($haystack, $needle, $offset);
else {
$min = false;
foreach($needle as $n) {
$pos = strpos($haystack, $n, $offset);
if($min === false || $pos < $min) {
$min = $pos;
}
}
return $min;
}
}