超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<resetshuffle>
Last updated: Fri, 22 Jun 2007

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()




add a note add a note User Contributed Notes
rsort
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.

<resetshuffle>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22