//按照传入数组中的num倒序 public function numdesc($array,$key="num",$order="desc"){ $arr_nums=$arr=array(); foreach($array as $k=>$v){ $arr_nums[$k]=$v[$key]; } if($order=='asc'){ asort($arr_nums); }else{ arsort($arr_nums); } foreach($arr_nums as $k=>$v){ $arr[$k]=$array[$k]; } return $arr; }