1、sql查询排序参数是order by,那么php进行排序呢

可以参考array_multisrot函数

//php进行二维数组排序  -xzz1009
foreach($home as $home){
    $ages[] = $home['s_id'];
}
$home = array_multisort($ages, SORT_DESC, $home);
//end

var_dump($home)即可查看。

2、如果想实现多个字段排序,即s_id倒序、age正序,可以参考下面代码:

foreach($home as $home){
    $s_ids[] = $home['s_id'];
    $ages[] = $home['age'];
}
$home =array_multisort($s_ids, SORT_DESC, $ages, SORT_ASC, $home);
//var_dump($home);

 

3、其中,以s_id是二维数组里面的一维数组索引。

相关文章:

  • 2022-02-18
  • 2021-10-30
  • 2021-09-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-12
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案