I have array like this
a1 = {1,3,5,7,9};
a2 = {2,4,6,8,9};
In both the arrays, there is a common value 9. I would like to know if there is a built in php function present which returns true or false if at least one value matches or not.
Thanks
I have array like this
a1 = {1,3,5,7,9};
a2 = {2,4,6,8,9};
In both the arrays, there is a common value 9. I would like to know if there is a built in php function present which returns true or false if at least one value matches or not.
Thanks
You can use array_intersect
function in PHP. Documentation.
Example
$a = array(1, 3, 5, 7);
$b = array(1, 2, 3, 4);
$haveMatch = (array_intersect($a, $b))?true:false;
echo $haveMatch;
You could use array_intersect
$a1 = [1,3,5,7,9];
$a2 = [2,4,6,8,9];
$a3 = [10];
array_intersect($a1,$a2) ? true : false;
// => true
array_intersect($a1,$a3) ? true : false;
// => false