我有以下代码:
while($row12 = mysql_fetch_array($result12)) {
$position = $row12['position'];
$tot[$k] = $row12['total'];
$k++;
}
$arr = arsort($tot);
for($x = 0; $x < $k; $x++) {
echo $tot[$x]."<br>";
}
我已经能够从数据库记录中创建总计数组,但需要按降序对值进行排序。
例如,在排序之前:
- 107
- 563
- 109
- 246
- 897
排序后:
- 897
- 563
- 246
- 109
- 107