|
$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( ) 主站蜘蛛池模板: 赖小子电影| 可爱美女跳舞蹈视频| baoru| 英语书七年级下册单词表| 韩奕| 夫妻的情妇| 老司机免费在线观看| 校园风暴| 同志电影网站| 张静初三体电影| 无耻之徒阿曼达| 饥渴女人的外遇| 香蜜沉沉烬如霜吻戏| 跨世王妃奇遇短剧免费观看| 极品电影网| 欧美变态sososo另类| 黑暗森林 电影| 749局什么时候上映| 安吉拉电影| 女子监狱第五季| 电视剧《唐太宗李世民》| 杰深斯坦森全部电影| 深海蛇难 电影| 黑太阳731在线观看| 薄冰演员表| 补充电解质喝什么饮料| 电影白上之黑| 音乐僵尸演员表| 伦理 在线| 法医秦明1至6部顺序| 炊事班的故事演员表| 猎魔人电影| 微信头像图片2024最新| 王渝萱的电影| 97理伦| 刀郎歌曲简谱| 十个世界尽头| 喜欢小红帽的原因怎么写| 林蛟| 驱魔保安| 蜂鸟演员表|