$array =[
['name' => 'ab' ,'phone' =>'111' ,'reg' =>'1211'] ,
['name' => 'abc' ,'phone' =>'111' ,'reg' =>'1212'] ,
['name' => 'abd' ,'phone' =>'111' ,'reg' =>'1213'] ,
['name' => 'ab' ,'phone' =>'1112' ,'reg' =>'1214'] ,
['name' => 'ab' ,'phone' =>'111' ,'reg' =>'1216'] ,
['name' => 'ab' ,'phone' =>'1113' ,'reg' =>'1217'] ,
['name' => 'ab' ,'phone' =>'111' ,'reg' =>'1218'] ,
] ;
function array_unique_fb($array2D){
$temp = [];
foreach ($array2D as $v) {
$key = $v['name'].'_'.$v['phone'];
$temp[$key] =$v['reg'];
}
$newarray =[];
$keys =array_keys($temp);
for ($i = 0; $i < count($temp); $i++) {
$a = explode('_',$keys[$i]);
$newarray[$i]['reg'] = $temp[$keys[$i]];
$newarray[$i]['name'] = $a[0];
$newarray[$i]['phone'] = $a[1];
}
return $newarray;
}
常用算法题目
最新推荐文章于 2022-03-07 22:03:05 发布