//二维数组排序, $arr是数据,$keys是排序的健值,$order是排序规则,1是升序,0是降序
1 function array_sort( $arr , $keys , $order = 0 ) {
2 if ( ! is_array ( $arr )) {
3 return false ;
4 }
5 $keysvalue = array ();
6 foreach ( $arr as $key => $val ) {
7 $keysvalue [ $key ] = $val [ $keys ];
8 }
9 if ( $order == 0 ){
10 asort ( $keysvalue );
11 } else {
12 arsort ( $keysvalue );
13 }
14 reset ( $keysvalue );
15 foreach ( $keysvalue as $key => $vals ) {
16 $keysort [ $key ] = $key ;
17 }
18 $new_array = array ();
19 foreach ( $keysort as $key => $val ) {
20 $new_array [ $key ] = $arr [ $val ];
21 }
22 return $new_array ;
23 }