在php中将数组合并到另一个多数组的特定元素中
我有第一个数组,看起来像这样:在php中将数组合并到另一个多数组的特定元素中,php,arrays,Php,Arrays,我有第一个数组,看起来像这样: Array ( [0] => Array ( [data] => Array ( [id] => 1 [type] => asset [description] => Real Estate [value] => 350000 )
Array
(
[0] => Array
(
[data] => Array
(
[id] => 1
[type] => asset
[description] => Real Estate
[value] => 350000
)
)
)
第二个数组如下所示:
Array
(
[0] => Array
(
[owners] => Array
(
[data] => Array
(
[id] => 1
[percentage] => 100
)
)
)
)
Array
(
[0] => Array
(
[data] => Array
(
[id] => 1
[type] => asset
[description] => Real Estate
[value] => 350000
[owners] => Array
(
[data] => Array
(
[id] => 1
[percentage] => 100
)
)
)
)
)
我需要在“数据”级别将第二个数组插入到第一个数组中,因此看起来如下所示:
Array
(
[0] => Array
(
[owners] => Array
(
[data] => Array
(
[id] => 1
[percentage] => 100
)
)
)
)
Array
(
[0] => Array
(
[data] => Array
(
[id] => 1
[type] => asset
[description] => Real Estate
[value] => 350000
[owners] => Array
(
[data] => Array
(
[id] => 1
[percentage] => 100
)
)
)
)
)
我尝试了array_merge,但输出并不像我预期的那样。第二个数组的常规附加到第一个数组只是将其添加到第一个数组的范围之外
有人能告诉我如何在上面显示的级别添加第二个吗?
thx
请向我们展示相关代码,这将使我们更容易确定问题所在。
$array1[0]['data']['owners']=$array2[0]['owners']
$array1[0]['data']['owners']=$array2[0]['owners']