php多维数组去重

时间:2022-08-21 19:03:09
<?php
$arr1[0]= ['id'=>1,'name'=>'test'];
$arr1[1]=['id'=>2,'name'=>'test'];

$arr3[0]= ['id'=>1,'name'=>'test'];
$arr3[1]=['id'=>2,'name'=>'test2'];

$arr2 = [0=>['id'=>1,'name'=>'test'],
         1=>['id'=>2,'name'=>'test2']
        ];
$b = array_merge($arr1,$arr3);//合并数组
$b = array_unique($b, SORT_REGULAR);
var_dump($b);
?>