Currently I have 2 array:
array(1, 2, 3, 4);
array(4, 5, 6, 7);
How can I check if there is at least one equal value in both of them? (The
array_intersect()
returns an array containing all the values of array1 that are present in all the arguments. Note that keys are preserved
$a = array(1, 2, 3, 4);
$b = array(4, 5, 6, 7);
$c = array_intersect($a, $b);
if (count($c) > 0) {
var_dump($c);
//there is at least one equal value
}
you get
array(1) {
[3]=>
int(4)
}