我正在尝试将另一个子数组添加到最后一个子数组。
这是我的数组的示例,
Array
(
[Auto-Trail] => Array
(
[name] => Auto-Trail
[children] => Array
(
[2001] => Array
(
[name] => 2001
[children] => Array
(
[Tracker] => Array
(
[name] => Tracker
[children] => Array
(
[CK] => Array
(
[name] => CK
[children] => Array
(
[Fiat] => Array
(
[name] => Fiat
)
)
)
[EK] => Array
(
[name] => EK
[children] => Array
(
[Fiat] => Array
(
[name] => Fiat
)
)
)
)
)
[Cheyenne] => Array
(
[name] => Cheyenne
[children] => Array
(
[630S] => Array
(
[name] => 630S
[children] => Array
(
[Fiat] => Array
(
[name] => Fiat
)
[Merc] => Array
(
[name] => Merc
[children] => Array
(
[313] => Array
(
[name] => 313
)
[316] => Array
(
[name] => 316
)
)
)
)
)
[630] => Array
(
[name] => 630
[children] => Array
(
[Fiat] => Array
(
[name] => Fiat
)
[Merc] => Array
(
[name] => Merc
[children] => Array
(
[313] => Array
(
[name] => 313
)
[316] => Array
(
[name] => 316
)
)
)
)
)
[634] => Array
(
[name] => 634
[children] => Array
(
[Fiat] => Array
(
[name] => Fiat
)
[Merc] => Array
(
[name] => Merc
[children] => Array
(
[313] => Array
(
[name] => 313
)
[316] => Array
(
[name] => 316
)
)
)
)
)
[634U] => Array
(
[name] => 634U
[children] => Array
(
[Fiat] => Array
(
[name] => Fiat
)
[Merc] => Array
(
[name] => Merc
[children] => Array
(
[313] => Array
(
[name] => 313
)
[316] => Array
(
[name] => 316
)
)
)
)
)
这是我希望添加到每个最后一个元素的数组,
例如,我需要将以下内容添加到 [CK][children][Fiat][children] (以及每个最后一个孩子的孩子) - 这个数组将是静态的,每个最后一个孩子都将使用相同的数组。
[BOF] => Array
(
[name] => Furniture
)
[CHA] => Array
(
[name] => Chassis
)
所以... ][CK][children][Fiat] 会变成下面这样,
[CK] => Array
(
[name] => CK
[children] => Array
(
[Fiat] => Array
(
[name] => Fiat
[children] => Array
(
[BOF] => Array
(
[name] => Furniture
)
[CHA] => Array
(
[name] => Chassis
)
)
)
)
)
请注意,并非每个最后一个孩子的缩进级别都相同,可能还有 10 个孩子缩进。它必须使用每个数组的数组中的最后一个数组。
抱歉,如果很难理解,我正在努力准确地说出我需要它的工作方式。
感谢您的时间和精力。