|
$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( ) 主站蜘蛛池模板: 国产精品久久久久久久久久久 | 国内精品视频久久久久免费 | 网友自拍偷拍 | 亚洲欧美国产综合在线 | 国产成人精品综合在线观看 | 三级黄色在线看 | 亚洲国产在线精品国自产拍五月 | 伊人大香线蕉精品在线播放 | 超碰久久国产vs | 日韩欧美中文字幕在线 | 亚洲444777KKK在线观看 | 亚洲这里只有精品 | 97在线看视频福利免费 | 国产不卡在线观看视频 | 国产午夜精品福利久久 | 超碰在线视频 免费 | 中文无码热在线视频 | 无敌在线视频观看免费 | 校花在公车上被内射好舒 | 亚洲精品91| 99热这里精品 | 国内精品人妻无码久久久影院蜜桃 | 亚洲人人为我我为人人 | 久久热在线视频精品1 | 麻豆国产成人AV在线 | 日本不卡不码高清免费 | 香蕉动漫库 | www黄色大片 | 亚洲AV无码偷拍在线观看 | free性中国hd护士高清 | 成人在线视频在线观看 | 三级黄色在线视频中文 | 久久国内精品视频 | 亚洲午夜精品aaa级久久久久 | 国产香蕉尹人视频在线 | 国产伦精品一区二区免费 | 野花日本韩国视频免费高清观看 | 久久re热线视频精品99 | 久久婷婷丁香五月色综合啪免费 | 一级毛片免费视频网站 | 10分钟免费观看视频 |