|
$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:
復(fù)制代碼 代碼如下:
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:
復(fù)制代碼 代碼如下:
$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( ) 主站蜘蛛池模板: 爱情洗牌| 雪中悍刀行第一季演员表| 王源个人资料简介身高| 刑事侦缉档案3演员表| 电影田螺姑娘| 睡衣派对| 亚洲春黄| 素人片| 范一贤| 质量教育培训的首要内容是() (单选题)| 贼王之王| 妇女停经前有什么征兆| 恐怖地带| 只园| 尹雪喜演的全部电影免费观看| 江苏诗歌网| 我的女老师| 《可爱的小鸟》阅读答案| 路易·德·菲奈斯| 爱欲1990未删减版播放| 《灿烂的季节》大结局| china中国农村妇女aⅴ| 那些女人电视剧免费观看全集剧情| 电视剧狙击手免费全集播放| 鬼吹灯之精绝古城演员表| 时来运转电影| 口加一笔变新字有几个| 无内裤秘书| 日本十大歌姬排名| kaori主演电影在线观看| 少女戏春潮| 朱莉安妮全集高清免费| 蛇欲电影| 邪教档案| 怒放的生命简谱| 雪暴 电影| 1988年英国的白蛇传说| 八年级上册英语第三单元2b翻译| 范艳华| 奶酪鼠的穷途梦2| 我等伊人来简谱|