Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php检查一个数组与另一个数组的所有匹配项_Php_Arrays - Fatal编程技术网

php检查一个数组与另一个数组的所有匹配项

php检查一个数组与另一个数组的所有匹配项,php,arrays,Php,Arrays,我有两个列有人的数组,我试图找出两个数组中都有哪些人 $employees = Array("bob", "john", "jerry", "mike"); $homies = Array("bob", "john", "arnold"); 我基本上需要知道哪些人既是员工又是同事(在本例中是bob和john),这样我就有了一个新的阵列: $employees_and_homies = Array("bob", "john"); 我在这里看了十几个问题,但我迷路了,这件案子什么都没用 : @参

我有两个列有人的数组,我试图找出两个数组中都有哪些人

$employees = Array("bob", "john", "jerry", "mike");
$homies = Array("bob", "john", "arnold");
我基本上需要知道哪些人既是员工又是同事(在本例中是bob和john),这样我就有了一个新的阵列:

$employees_and_homies = Array("bob", "john");
我在这里看了十几个问题,但我迷路了,这件案子什么都没用

@参考:

$employees_and_homies = array_intersect($employees, $homies);
print_r(array_intersect ($employees, $homies));