I think you want array_intersect():
$matches = array_intersect($foo, $bar);
$matches will return an array of all elements in both arrays so you can:
- Check for matches with
empty($matches) - Read the number of matches with
count($matches) - Read intersection values if you need to
Link: http://php.net/manual/en/function.array-intersect.php
An example for your case:
$foo = array("ESD", "RED", "IOP");
$bar = array("IOD", "MNP", "JDE", "RED");
// Just cast to boolean
if ((bool) array_intersect($foo, $bar)) // true because RED is in $foo and in $bar
source
share