我尝试了以下方法:
$tree['uid1']['page'] = "page1";
$tree['uid1']['childs']['uid2']['page'] = "page2";
$tree['uid1']['childs']['uid3']['page'] = "page3";
array_walk_recursive($tree, function (&$item, $key) {
echo $key.', ';
if ($key == 'uid3') {
// push array('childs' => array('uid4' => array('page' => 'page4')))
}
});
但是 echo $key.', '; 只返回最后一个键(“page”) 我做错了什么还是我误解了函数“array_walk_recursive”