|
$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费观看视频+播放器 | 亚洲一二三四 | 亚洲图片88| 久久青青草原精品无线观看 | 亚洲视频国产 | 真实国产乱子伦在线观看 | 久国产精品久久精品国产四虎 | 香蕉成人国产精品免费看网站 | 女人张腿给男人桶视频免费版 | 久伊人网 | 久久精品视频99精品视频150 | 四虎sihu新版影院亚洲精品 | 一级女人毛片 | 91精品免费国产高清在线 | 精品久久久久久中文 | 欧色视频 | 在线观看欧美视频 | 岛国一级毛片 | 欧美亚洲三级 | 国内精品久久久久久中文字幕 | 一区二区不卡视频 | 91视频观看 | 色哟哟视频在线观看网站 | 欧美日韩在线视频 | 性欧美videosg最新另类 | 久久国产精品一区二区三区 | 日本人视频18jizz免费 | 欧美成人三级伦在线观看 | 男人女人的免费视频网站 | 国产一区二区三区在线视频 | 色综合88 |