数组对比取差异的值
程序员文章站
2022-04-07 18:32:18
...
$data1 = [1,2,3];
$data2 = [3,4,5];
$d1 = array_intersect($data1,$data2);//取出重复的值 ['2'=>3]
$d2 = array_diff($data1,$data2);//$data1对比去重,然后取剩余的值 ['0'=>1,'1'=>2]
$d3 = array_diff($data2,$data1);//$data2对比去重,然后取剩余的值 ['1'=>4,'2'=>5]