|
$full_name = array();
$full_name["Roger"] = "Waters";
$full_name["Richard"] = "Wright";
$full_name["Nick"] = "Mason";
$full_name["David"] = "Gilmour";
To sort this array, you just use the assort( ) function. This involves nothing more complex than typing the word asort, followed by round brackets. In between the round brackets, type in the name of your Associative array:
復制代碼 代碼如下:
asort($full_name);
The letter "a" tells php that the array is an Associative one. (If you don't have the "a" before "sort", your key names will turn in to numbers!). The "a" also tells php to sort by the Value, and NOT by the key. In our script above, the surnames will be sorted. If you want to sort using the Key, then you can use ksort() instead.
If you have a Scalar array (numbers as Keys), then you leave the "a" off. Like this:
復制代碼 代碼如下:
$numbers = array( );
$numbers[]="2";
$numbers[]="8";
$numbers[]="10";
$numbers[]="6";
sort($numbers);
print $numbers[0] ;
print $numbers[1];
print $numbers[2] ;
print $numbers[3];
The numbers are then sorted from lowest to highest. If you want to sort in reverse order then you need the following:
rsort( ) 主站蜘蛛池模板: 久久精品亚洲欧美日韩久久 | 国产一区二区三区免费观看 | 狠狠干天天爱 | 麻豆国产91 | 亚洲激情专区 | 免费黄色在线 | 日韩中文字幕一在线 | 精品久久久久久影院免费 | 精品午夜视频 | 亚洲人成绝费网站色ww | 成人在线激情视频 | 国产精品欧美在线 | 久久久久久久成人午夜精品福利 | 欧美一区二区三区精品国产 | 丁香六月婷婷在线观看视频 | 91国视频在线 | 国产欧美一区二区精品性色tv | 涩视频永久免费 | 巨臀中文字幕一区二区翘臀 | 一起射福利 | 天天操夜夜做 | 久久91精品国产91久久麻豆 | 日本欧美一区二区三区视频 | 国产精品资源网站在线观看 | 在线观看亚洲一区二区 | 国产成人精品久久亚洲高清不卡 | 色成网| 狠狠做狠狠做综合日日 | 久久丝袜精品综合网站 | 99视频精品免视3 | 国产在线观看91精品2022 | 欧美性活一级视频 | 亚洲视频久久 | 久久久噜噜噜久久久午夜 | 特级xxxxx欧美 | 女人一级一级毛片 | 久久香蕉网 | 伊人免费在线 | 亚洲天堂久久精品 | 五月亚洲 | 天天干天天天天 |