Answers for "check for one of multiple values in string php"

PHP
4

php find multiple strings in string

if(preg_match('(bad|naughty)', $data) === 1) { }
Posted by: Guest on April-03-2020
1

php check if any of multiple values in array

function in_array_any($needles, $haystack) {
   return !empty(array_intersect($needles, $haystack));
}

echo in_array_any( [3,9], [5,8,3,1,2] ); // true, since 3 is present
echo in_array_any( [4,9], [5,8,3,1,2] ); // false, neither 4 nor 9 is present
Posted by: Guest on February-07-2021

Code answers related to "check for one of multiple values in string php"

Browse Popular Code Answers by Language