这里主要是rsort krsort函数,他是对键名进行反序排序了,如果要数组元素值排序用sort就成了,array_multisort这个是对多维数组排序.
- */
- $array = array(array('www.Vevb.com',6,8),array(1,2,6));
- print_r($array);
- /*
- array
- (
- [0] => array
- (
- [0] => www.Vevb.com
- [1] => 6
- [2] => 8
- )
- [1] => array
- (
- [0] => 1
- [1] => 2
- [2] => 6
- )
- )
- */
- array_multisort($array) ;//对二维数组进行排序
- print_r($array);
- /*
- array
- (
- [0] => array
- (
- [0] => www.Vevb.com
- [1] => 6
- [2] => 8
- )
- [1] => array
- (
- [0] => 1
- [1] => 2
- [2] => 6
- )
- )
- */
- $ar = array('Vevb.com',2,3,5);
- rsort($ar);
- print_r($ar);
- /*
- array
- (
- [0] => 5
- [1] => 3
- [2] => 2
- [3] => Vevb.com
- )
- */
- krsort($ar);
- print_r($ar);
- /*
- array
- (
- [3] => Vevb.com
- [2] => 2
- [1] => 3
- [0] => 5
- )*/
新闻热点
疑难解答