这里主要是rsort krsort函数,他是对键名进行反序排序了,如果要数组元素值排序用sort就成了,array_multisort这个是对多维数组排序。
*/
$array = array(array('www.111cn.net',6,8),array(1,2,6));
print_r($array);
/*
array
(
[0] => array
(
[0] => www.111cn.net
[1] => 6
[2] => 8
)
[1] => array
(
[0] => 1
[1] => 2
[2] => 6
)
)
*/
array_multisort($array) ;//对二维数组进行排序
print_r($array);
/*
array
(
[0] => array
(
[0] => www.111cn.net
[1] => 6
[2] => 8
)
[1] => array
(
[0] => 1
[1] => 2
[2] => 6
)
)
*/
$ar = array('111cn.net',2,3,5);
rsort($ar);
print_r($ar);
/*
array
(
[0] => 5
[1] => 3
[2] => 2
[3] => 111cn.net
)
*/
krsort($ar);
print_r($ar);
/*
array
(
[3] => 111cn.net
[2] => 2
[1] => 3
[0] => 5
)*/