Copy code The code is as follows:
function assoc_unique($arr, $key) {
$ tmp_arr = array(); $k]); arr);
return $arr;
}
$aa = array(
array('id' => 123, 'name' => 'Zhang San'),
array('id' => ; 123, 'name' => '李思'),
array('id' => 124, 'name' => '王五'),
array('id' => ; 125, 'name' => 'Zhao Liu'),
array('id' => 126, 'name' => 'Zhao Liu')
);
$key = 'name';
assoc_unique(&$aa, $key);
print_r($aa);
?>
http://www.bkjia.com/PHPjc/326485.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/326485.html
TechArticleCopy the code as follows: ?php function assoc_unique($arr, $key) { $tmp_arr = array(); foreach($arr as $k = $v) { if(in_array($v[$key], $tmp_arr)) { unset($arr[$k]); } else { $tmp...