PHP 二维按照某个字段对数组排序
作者:互联网
function arraySort($arr, $keys, $type = 'asc') {//二维按照某个字段对数组排序 $keysvalue = $new_array = array(); foreach ($arr as $k => $v){ $keysvalue[$k] = $v[$keys]; } $type == 'asc' ? asort($keysvalue) : arsort($keysvalue); reset($keysvalue); foreach ($keysvalue as $k => $v) { $new_array[$k] = $arr[$k]; } return $new_array; }
标签:arr,keysvalue,keys,二维,asc,字段,new,array,PHP 来源: https://www.cnblogs.com/Caray/p/16462324.html