我有一个问题 不排序所以我有此数组:递归ksort:数组
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
)
)
我想排序键递归。所以,我创建了Methode:
public function sortNestedArrayAssoc($a)
{
if (!is_array($a)) {
return false;
}
ksort($a);
foreach ($a as $k=>$v) {
$this->sortNestedArrayAssoc($a[$k]);
}
return true;
}
,但我得到了相同的结果,关键23
阵列是第一,我不真正了解问题出在哪里。你能帮我吗 ? Thx提前对不起我的英文
您需要通过引用来传递方法arg。 –