You could use array_diff
to compute the difference between the $a
array against $array
. This would give you all the values not in $array
or $a
.
Example from Manual:
$array1 = array("a" => "green", "red", "blue", "red");
$array2 = array("b" => "green", "yellow", "red");
print_r( array_diff($array1, $array2) );
Array
(
[1] => blue
)
Or you can use array_intersect
to find those that are in those arrays.
array_intersect
Example from PHP Manual:
$array1 = array("a" => "green", "red", "blue");
$array2 = array("b" => "green", "yellow", "red");
print_r( array_intersect($array1, $array2) );
Array
(
[a] => green
[0] => red
)
Pick the one you need.