This article mainly introduces the PHP two-dimensional array deduplication according to a certain element, which has a certain reference value. Now I share it with you. Friends in need can refer to it
function array_unset($arr,$key){ //建立一个目标数组 $res = array(); foreach ($arr as $value) { //查看有没有重复项 if(isset($res[$value[$key]])){ //有:销毁 unset($value[$key]); } else{ $res[$value[$key]] = $value; } } return $res; } $arr = array( array( 'title'=>'1111','date'=>'ddddd' ), array('title'=>'22222','date'=>'fffffff'), array('title'=>'1111','date'=>'ggggggg') ); $newArr = array_unset_tt($arr,'title'); echo '<pre class="brush:php;toolbar:false">'; print_r(array_values($newArr));
Related recommendations:
PHP two-dimensional array sorting by key value
php two-dimensional array deduplication method
The above is the detailed content of PHP two-dimensional array deduplication based on a certain element. For more information, please follow other related articles on the PHP Chinese website!