我有一个数组,我想要它的评级意味着记录应该从高到低和
注意:我用这个得到了完美的结果。但我也使用了分页。 当我在第1页的记录已经显示我想要的。但是当我进入第2页。它会再次排序。
我希望所有记录都排序,然后输出应该显示。
感谢。
$array[] = array(
"id"=>$data->id,
"name" => $data->name,
"delivery_time" => $data->delivery_time,
"currency" => $data->currency,
"image" => $data->photo,
"lat" => $data->lat,
"lon" => $data->lon,
"Category" => $category,
"ratting" => $ratting,
"res_status" => $openclose,
"distance"=>$data->distance,
"distancekm" => "$km",
"open_time"=>$data->open_time,
"close_time"=>$data->close_time
);
if ($_GET['short_by'] == 'ratting') {
usort($array, function ($a, $b) {
return $a['ratting'] < $b['ratting'];
});
return $array;
}