PHP 两个二维数组求交集

思路,循环其中一个数组,然后使用in_array() 函数,判断被循环数组的每个元素是否在另外一个数组中即可

   代码如下:

    

 $out_arr = array(); //交集或者是不重复的数组
        if(!empty($res_repeat)){
            //Wipe off the mac that in the mac_array
            foreach($mac_array as $key=>$item){
                if(!in_array(array("mac_addr"=>$item),$res_repeat)){
                    $out_arr[]=$item;
                }
            }
        }else{
            $out_arr = $mac_array;
        }

  只需要输出$out_arr即可