可能重复:
如何在 php 中对多维数组进行排序
我有多维数组,例如:
$mas = array("s",array("c","b","a"),array(3,5,1),"a",array("s",array("z","一种”)));
我想对所有数组元素进行排序(升序),我编写了递归函数,但它不起作用,请告诉我,我错了?
$mas = array("s",array("c","b","a"),array(3,5,1),"a",array("s",array("z","a")));
function sortsort($m) {
sort($m);
foreach ($m as &$v) {
if (is_array($v)) {
sortsort($v);
}
}
return $m;
}
var_dump(sortsort($mas));