-
- /* Two-dimensional array is sorted by the specified key value
- * $array array
- * $key sort key value
- * $type sorting method
- * @edit: bbs.it-home. org
- */
- function array_sort($arr, $keys, $type = 'desc') {
- $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;
- }
Copy code
>>> For more information, please view the complete list of php array sorting methods
|