A simple way to do this is to use array_intersect and check if it isn't empty.
$a = array('able','baker','charlie');
$b = array('zebra','yeti','xantis');
echo !!array_intersect($a, $b) ? 'true' : 'false'; //false
$a = array('able','baker','charlie');
$b = array('zebra','yeti','able','xantis');
echo !!array_intersect($a, $b) ? 'true' : 'false'; //true
Or you can make a simple function to check if there is at least one intersection. This is faster than the first one because it doesn't have to find all the intersections. When it finds one, it returns true at that moment.
function check_for_intersect($a, $b) {
$c = array_flip($a);
foreach ($b as $v) {
if (isset($c[$v])) return true;
}
return false;
}
$a = array('able','baker','charlie');
$b = array('zebra','yeti','xantis');
echo check_for_intersect($a, $b) ? 'true' : 'false';
$a = array('able','baker','charlie');
$b = array('able','zebra','yeti','xantis');
echo check_for_intersect($a, $b) ? 'true' : 'false';