|
|
 |
rsort (PHP 3, PHP 4 , PHP 5) rsort -- 对数组逆向排序 说明void rsort ( array array [, int sort_flags])
本函数对数组进行逆向排序(最高到最低)。
例子 1. rsort() 例子 |
<?php
$fruits = array ("lemon", "orange", "banana", "apple");
rsort ($fruits);
reset ($fruits);
while (list ($key, $val) = each ($fruits)) {
echo "$key = $val\n";
}
?>
|
本例将显示:
0 = orange
1 = lemon
2 = banana
3 = apple |
|
fruits 被按照字母顺序逆向排序。
可以用可选参数 sort_flags
改变排序的行为,详情见 sort()。
参见 arsort(),asort(),ksort(),sort()
和 usort()。
slevy1 at pipeline dot com
13-Jun-2001 02:15
I thought rsort was working successfully or on a multi-dimensional array of
strings that had first been sorted with usort(). But, I noticed today that
the array was only partially in descending order. I tried array_reverse
on it and that seems to have solved things.
| |