php代码
<?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_arr[] = $v[$key]; } } sort($arr); return $arr; } $aa = array( array('id' => 123, 'name' => '张三'), array('id' => 123, 'name' => '李四'), array('id' => 124, 'name' => '王五'), array('id' => 125, 'name' => '赵六'), array('id' => 126, 'name' => '赵六') ); $key = 'name'; assoc_unique(&$aa, $key); print_r($aa); ?>