php check if two arrays have same values 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: php check if all array values are the same
if (count(array_unique($allvalues)) === 1 && end($allvalues) === 'true') {
}
if (in_array('false', $allvalues, true)) {
}
Example 3: check if any values are the same in an array php
if(count(array_unique($array, SORT_REGULAR)) < count($array)) {
} else {
}