一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

Sorting Array Values in PHP(數組排序)

復制代碼 代碼如下:
$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( ) 主站蜘蛛池模板: 在线观看黄视频 | aa级国产女人毛片水真多 | 15p亚洲 | 精品大臿蕉视频在线观看 | 午夜影院日韩 | 97国产成人精品免费视频 | 亚洲六月丁香婷婷综合 | 欧美色网络 | 色老板在线免费视频 | 黄址在线观看 | 国产视频二区 | 福利小视频在线播放 | 六月婷婷激情综合 | 亚洲欧美日韩综合一区 | 亚洲精品视频二区 | 麻豆 国产 | 看全色黄大色大片免费 | 91一区二区三区 | www.夜夜操| 五月婷婷婷 | 奇米影视99 | 精品视频在线免费 | 久视频在线观看久视频 | 婷婷涩五月 | 成人午夜在线观看国产 | 日本特级a禁片在线播放 | 每日更新国产精品视频 | 国产一区二区三区精品视频 | 男人精品网站一区二区三区 | 亚洲日本一区二区三区在线 | 在线色网址 | 国产色婷婷精品综合在线观看 | 色偷偷人人澡久久天天 | 日本久久久久久久中文字幕 | 国产精品欧美在线不卡 | 久久久国产一区二区三区 | 黄篇网站在线观看 | 999国内精品永久免费视频 | 国产91精品福利在线观看 | 51国产偷自视频区视频手机播器 | 99视频都是精品热在线播放 |