一个不错的PHP二维数组排序函数简单易用存用
传入数组,传入排序的键,传入排序顺序
public function array_sort($arr,$keys,$type='asc') { $keysvalue = $new_array = array(); foreach ($arr as $k=>$v){ $keysvalue[$k] = $v[$keys]; } if($type == 'asc'){ asort($keysvalue); }else{ arsort($keysvalue); } reset($keysvalue); foreach ($keysvalue as $k=>$v){ $new_array[$k] = $arr[$k]; } return $new_array; }