PHP二维数组按某个字段排序

时间:2022-01-29 00:12:47
//准备 二维数组

//按一个字段排序
foreach($rank as $key=>$val){
$dos[$key] = $val['timelength'];
}
array_multisort($dos,SORT_ASC,$rank); var_dump($rank);

  

//按两个字段先后排序
foreach($rank as $key=>$val){
  $dos[$key] = $val['timelength'];
  $ds[$key] = $val['join_time'];
}
array_multisort($dos,SORT_ASC,$ds,SORT_ASC,$rank); var_dump($rank);

  

PHP二维数组按某个字段排序