我有一个生成这种数组的函数:
数组([0] => 1 [id] => 1 [1] =>主页 [slug] => home [2] => [parent_id] => [3] => 1 [发布] => 1 [4] =>内容 [type] =>内容
[id_2] =>阵列( [0] => 2 [id] => 2 [1] => 404_error [slug] => 404_error [2] => 1 [parent_id] => 1 [3] => 1 [发布] => 1 [4] => content [type] =>内容))
我需要一个函数,它允许我在这个数组中找到id_x,并在它出现的数组中追加一个新数组,而不管所需的id_x键所在的deph。
就像这样
数组([0] => 1 [id] => 1 [1] =>主页 [slug] => home [2] => [parent_id] => [3] => 1 [发布] => 1 [4] =>内容 [type] =>内容
[id_2] =>阵列( [0] => 2 [id] => 2 [1] => 404_error [slug] => 404_error [2] => 1 [parent_id] => 1 [3] => 1 [发布] => 1 [4] => content [type] =>内容
[id_3] =>数组([0] => 3 [id] => 3 [1] => generic [slug] => generic [2] => 2 [parent_id] => 2 [3] => 1 [发布] => 1 [4] =>表格[type] =>形式))))
I.E [parent_id]匹配id_x,插入一个新数组。
我查看了手册,看起来似乎完全不合适。
当前数组上的var_export:
array('id_1'=> array(0 =>'1', 'id'=> '1',1 => 'home','slug'=> 'home',2 => '','parent_id'=> '',3 => '1','发布'=> '1',4 => 'content','type'=> 'content','id_2' =>数组(0 =>'2','id'=>'2',1 =>'404_error','slug'=>'404_error',2 => '1','parent_id'=> '1',3 => '1','发布'=> '1',4 => '内容', 'type'=> 'content',),),'id_7'=> 数组(0 =>'7','id'=>'7',1 => 'login_expiry','slug'=> 'login_expiry',2 => '','parent_id' => '',3 => '1','发布'=> '1',4 => 'content','type'=> 'content','id_4'=>数组(0 =>'4','id'=> '4',1 => 'login_expiry','slug'=> 'login_expiry',2 => '7','parent_id' => '7',3 => '0','发布'=> '0',4 => 'content','type'=> 'content',),),'id_2'=>数组('id_3'=>数组( 0 => '3','id'=> '3',1 => “通用”, 'slug'=> 'generic',2 => '2', 'parent_id'=> '2',3 => '1', 'publish'=> '1',4 => '形式','类型' => 'forms',),),'id_4'=> array('id_5'=> array(0 =>'5','id'=> '5',1 => '404_error','slug'=> '404_error',2 => '4','parent_id'=> '4',3 => '1','发布'=> '1',4 => 'content','type'=> 'content',),), 'id_5'=>数组('id_6'=>数组(0 => '6','id'=> '6',1 => 'generic','slug'=> 'generic',2 => '5', 'parent_id'=> '5',3 => '1', 'publish'=> '1',4 => '形式','类型' => 'forms',),),)