【发布时间】:2021-05-01 10:21:57
【问题描述】:
如何将新数组插入到多维数组的特定位置下面是代码,如何使用php完成
$aExistingArray = Array
(
[pages] => Array
(
[0] => Array
(
[name] => page1
[elements] => Array
(
[0] => Array
(
[type] => text
[name] => question2
[title] => PSTN
)
[1] => Array
(
[type] => radiogroup
[name] => question3
[title] => Are you satisfied to our services
[choices] => Array
(
[0] => Array
(
[value] => item1
[text] => yes
)
[1] => Array
(
[value] => item2
[text] => no
)
)
)
)
)
))
下面是我要插入到 elements 位置 0 位置的新数组,它将如何使用数组技术完成
$aToBeInserted = Array
(
[0] => Array
(
[type] => text
[name] => name
[title] => name
)
[1] => Array
(
[type] => text
[name] => question1
[title] => Test
)
)
【问题讨论】:
-
您要插入什么数组?您只在上面的帖子中提供了原始数组。
-
链接副本为您提供了机制。您真正需要提供的只是新元素和您希望插入的确切子数组。
-
@El_Vanja 新元素已发布请查收
-
@BlakeOttinger 问题已编辑,请检查