Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #check #multiple #values #array
ADD COMMENT
Topic
Name
9+2 =