标签:eric des desc 修改 字符 情况 als array 信息
array_multisort --对多个数组或者多维数组进行排序[参考:secure.php.net]
说明:
bool array_multisort ( array &$array1 [, mixed $array1_sort_order = SORT_ASC [, mixed $array1_sort_flags = SORT_REGULAR [, mixed $... ]]] )
array_multisort() 可以用来一次对多个数组进行排序,或者根据某一维或多维对多维数组进行排序。
成功时返回TRUE,或失败时FALSE
$nums = array(1,4,5,2,9);
$str = array("a","g","i","z","k");
array_multisort($nums , SORT_DESC , $str);
print_r($nums);
print_r($str);
$arr = array(
array("spid"=>"1","time"=>100),
array("spid"=>"1","time"=>105),
array("spid"=>"2","time"=>104),
array("spid"=>"1","time"=>102),
array("spid"=>"2","time"=>101),
);
$spids = array();
$times = array();
foreach ($arr as $key => $value) {
$spids[] = $value[‘spid‘];
$times[] = $value[‘time‘];
}
//array_multisort($times,SORT_DESC ,$spids,SORT_ASC , $arr );
//先按照spids列降序,再按照times列升序
array_multisort($spids,SORT_ASC ,$times,SORT_DESC , $arr );
//array_multisort($spids,SORT_DESC , $arr );
print_r($arr);
9 5 4 2 1
k i g z a
["1":105,"1":102,"1":100,"2":104,"2":101]
标签:eric des desc 修改 字符 情况 als array 信息
原文地址:https://www.cnblogs.com/chq3272991/p/8969059.html