這篇文章主要介紹了php通過asort()給關(guān)聯(lián)數(shù)組按照值排序的方法,實(shí)例分析了php中asort()函數(shù)的功能與使用技巧,需要的朋友可以參考下
本文實(shí)例講述了php通過asort()給關(guān)聯(lián)數(shù)組按照值排序的方法。分享給大家供大家參考。具體分析如下:
php通過asort()給關(guān)聯(lián)數(shù)組按照值排序,和sort的區(qū)別是,sort為數(shù)組中的單元賦予新的鍵名。原有的鍵名將被刪除。
- $nums = array("one"=>5,"two"=>2,"three"=>1);
- asort( $nums );
- foreach ( $nums as $key => $val ) {
- print "$key = $val<br />";
- }
希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答