二维数组排序

1:创建二维数组

 $data = array();
 $data[$j]['teacher_id'] = $teacher_id;
 $data[$j]['total_score'] = $total_score;

2:数组排序

foreach ($data as $key => $row) {
    $volume[$key] = $row['total_score'];
    $edition[$key] = $row['teacher_id'];
}

array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $data);

3排序前后对比

排序前                             排序后

            

猜你喜欢

转载自blog.csdn.net/qq_29099209/article/details/80066526