Checking to see if one array's elements are in another array in PHP

前端 未结 7 1880
闹比i
闹比i 2020-11-27 13:26

I have two arrays in PHP as follows:

People:

Array
(
    [0] => 3
    [1] => 20
)

Wanted Criminals:

7条回答
  •  猫巷女王i
    2020-11-27 13:46

    There's little wrong with using array_intersect() and count() (instead of empty).

    For example:

    $bFound = (count(array_intersect($criminals, $people))) ? true : false;
    

提交回复
热议问题