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...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn