二维数组排序 PHP

$data = [
  ['name'=>'xxx','num' =>2],
  ['name'=>'fff','num' =>3],
  ['name'=>'ddd','num' =>7],
  ['name'=>'ddd','num' =>5],
]
$num = array_column($data,'num');//排序字段
array_multisort($num,SORT_DESC,$data) ;//按num字段降序排序

是否对您有用呢?有用就给个赞呗^^

你可能感兴趣的:(二维数组排序 PHP)