我很茫然。我用谷歌搜索,在这里搜索,阅读 php 手册几个小时,但我无法提出解决方案。
我得到以下数组结构:
[x] => Array
(
...
[object_name_1] => Array
(
[db] => x
[form] => y
[value] => z
)
...
[object_name_4] => Array
(
[db] => x
[form] => y
[value] => z
)
...
[object_name_n] => Array
(
[db] => x
[form] => y
[value] => z
)
...
[y] => Array
(
...
[object_group_xyz] => Array
(
[object_name_a] => Array
(
[db] => x
[form] => y
[value] => z
)
...
)
...
[object_name_e] => Array
(
[db] => x
[form] => y
[value] => z
)
...
[object_name_z] => Array
(
[db] => x
[form] => y
[value] => z
)
现在我的问题如下:我想保存所有 object_name_x 数组。数组的深度未知,事实上,不同object_name_n对象的深度可以依赖于同一个数组。但它们永远是最后一片叶子。
我怎么解决这个问题。据我所知, RecursiveIteratorIterator 没有办法只考虑倒数第二个对象。
我的输出应该是这样的:
Array
(
[object_name_1] => Array
(
[db] => x
[form] => y
[value] => z
)
...
[object_name_4] => Array
(
[db] => x
[form] => y
[value] => z
)
...
[object_name_n] => Array
(
[db] => x
[form] => y
[value] => z
)
...
[object_name_a] => Array
(
[db] => x
[form] => y
[value] => z
)
...
[object_name_e] => Array
(
[db] => x
[form] => y
[value] => z
)
...
[object_name_z] => Array
(
[db] => x
[form] => y
[value] => z
)
...
)
感谢您的时间和帮助!