how to check in array with multiple array in php code example
Example 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] );
echo in_array_any( [4,9], [5,8,3,1,2] );
Example 2: multiple value match in array php
$uniqueKeys = array_unique($list[0])
foreach ($uniqueKeys as $uniqueKey)
{
$v = array_keys($list[0], $uniqueKey);
if (count($v) > 1)
{
foreach ($v as $key)
{
}
}
}