|
$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 | 大乳boobs巨大吃奶挤奶 | 国产美女特级嫩嫩嫩bbb片 | 在线一区二区三区 | 91精品国产一区二区三区 | 精品一区免费 | 免费成年网站 | 日韩综合一区 | 亚洲精品国产精品国自产在线 | 中文字幕亚洲欧美日韩在线不卡 | 超碰精品在线 | 福利久久 | 精品国产乱码久久久久久丨区2区 | 欧美极品少妇xxxxⅹ免费视频 | 久久成人精品 | 日日摸日日碰夜夜爽亚洲精品蜜乳 | 在线看h| 国产精品特级毛片一区二区三区 | 羞视频在线观看 | 中文字幕在线观看第一页 | 国产一区免费 | 久久精品视频在线观看 | 免费毛片在线 | 久久国产精品亚洲 | 国产成在线观看免费视频 | 嫩草伊人 | 久久久久久国产精品免费免费男同 | 青青草av网站 | 亚洲性网| 91精品国产综合久久精品图片 | 91国内视频在线 | 特级黄一级播放 | 成人精品福利 | 国产一区91精品张津瑜 | 一区二区三区高清 | 日韩精品成人一区二区三区视频 | 日韩一区二区三区视频在线观看 | 欧美成人手机在线 |