php二维数组根据某个键去重
function array_unset_tt($arr, $key)
{
$res = array();
foreach ($arr as $value) {
if (isset($res[$value[$key]])) {
unset($value[$key]);
} else {
$res[$value[$key]] = $value;
}
}
return $res;
}
function arraySort($array,$keys,$sort='asc') {
$newArr = $valArr = array();
foreach ($array as $key=>$value) {
$valArr[$key] = $value[$keys];
}
($sort == 'asc') ? asort($valArr) : arsort($valArr);
reset($valArr);
foreach($valArr as $key=>$value) {
$newArr[$key] = $array[$key];
}
return $newArr;
}