Checking to see if one array's elements are in another array in PHP
You can use array_intersect()
.
$result = !empty(array_intersect($people, $criminals));
There's little wrong with using array_intersect() and count() (instead of empty).
For example:
$bFound = (count(array_intersect($criminals, $people))) ? true : false;
if 'empty' is not the best choice, what about this:
if (array_intersect($people, $criminals)) {...} //when found
or
if (!array_intersect($people, $criminals)) {...} //when not found