二维数组按照某一列排序 1. [代码] [PHP]代码 /** * 二维数组排序方法,数字的倒叙排列 * @param arr * @param field */function sortArrByField($array, $field, $desc = false){ $fieldArr = array(); foreach ($array as $k
1. [代码][PHP]代码
/** * 二维数组排序方法,数字的倒叙排列 * @param arr * @param field */ function sortArrByField(&$array, $field, $desc = false){ $fieldArr = array(); foreach ($array as $k => $v) { $fieldArr[$k] = $v[$field]; } $sort = $desc == false ? SORT_ASC : SORT_DESC; array_multisort($fieldArr, $sort, $array); return $array; }