【发布时间】:2016-06-09 15:12:21
【问题描述】:
我有一个问题 所以我有这个数组:
Array
(
[2016] => Array
(
[23] => Array
(
[total_auctions] => 0
[total_price] => 0
)
[22] => Array
(
[total_auctions] => 0
[total_price] => 0
)
[21] => Array
(
[total_auctions] => 0
[total_price] => 0
)
[20] => Array
(
[total_auctions] => 0
[total_price] => 0
)
)
我想按键递归排序。所以我创建了方法:
public function sortNestedArrayAssoc($a)
{
if (!is_array($a)) {
return false;
}
ksort($a);
foreach ($a as $k=>$v) {
$this->sortNestedArrayAssoc($a[$k]);
}
return true;
}
但是我得到了相同的结果,带有键 23 的数组是第一个,我真的不明白问题出在哪里。你能帮我吗 ?提前谢谢,对不起我的英语
【问题讨论】:
-
您需要通过引用传递方法arg。