|
$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( ) 主站蜘蛛池模板: 中文免费观看视频网站 | 日本精品久久久中文字幕 | 国产99视频精品草莓免视看 | 国产极品美女在线 | 2021最新在线精品国产 | 亚洲欧美在线观看 | 黄色avav| 国产xxxxx在线播放 | 91福利片| 四虎澳门永久8848在线影院 | 国产欧美一区二区三区观看 | 91视频看 | 视频免费1区二区三区 | 麻豆视频91 | 久久厕所精品国产精品亚洲 | 中文一区二区视频 | 5566av资源| 色狠狠一区二区三区香蕉蜜桃 | 亚洲视频第一页 | 久久综合丝袜长腿丝袜 | 91精品啪在线观看国产18 | 337p欧洲日本大胆艺术 | 亚洲激情99| 久久青草免费97线频观 | 午夜dj观看在线影院 | 美女又美女又黄又免费网站 | 色视频在线观看网站 | www.黄色.con| 亚洲国产成人综合 | 婷婷丁香激情五月 | 久久精品大片 | 黑人专区| 91av福利 | 国产精品久久久久影院色老大 | 在线激情网 | 亚洲激情图片网 | 一区二区在线视频观看 | 另类文字小说图片 | 国内精品久久久久激情影院 | 成人免费观看www视频 | 大jjjj免费看视频 |