|
$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( ) 主站蜘蛛池模板: 欧美国产亚洲精品a第一页 欧美国产一区二区二区 | 国产福利在线永久视频 | 国产精品400部自产在线观看 | 精品中文字幕一区二区三区四区 | 最新精品国偷自产在线91 | 国产人成亚洲第一网站在线播放 | 永久黄网站色视频免费观看 | 五月天婷婷精品视频 | 久久性感视频 | 免费一区二区三区在线视频 | 色多多在线免费观看 | 国产视频大全 | 国产免费成人在线视频 | 久久综合久久鬼色 | 九月婷婷亚洲综合在线 | 亚洲狠狠97婷婷综合久久久久 | 国内一级特黄女人精品毛片 | 美女被男人桶免费网站 | 一区二区三区四区在线视频 | 99热成人精品国产免男男 | 91视频免费观看高清观看完整 | 爱做久久久久久久久久 | 超级碰碰青草免费视频92 | 天堂成人精品视频在线观 | 韩国免费一级成人毛片 | 免费xxxxx在线观看网站 | 一个人免费播放在线视频看片 | 欧美黄区| 国产对白精品刺激一区二区 | 亚洲tv精品一区二区三区 | 色无极影院亚洲 | 国内第一永久免费福利视频 | 色哟哟在线网站 | 国产小视频福利 | 亚洲国产精品自在在线观看 | 日韩精品一区二区三区中文在线 | 国产精品久久久久久一级毛片 | 欧美午夜性刺激在线观看免费 | 亚洲欧美国产精品久久久 | www.色播| 视频一区二区三区在线观看 |