我想使用指定的深度子数组值组合两个数组。
我有两个具有不同结构的不同数组,我想将它们组合起来,以便如果“主键”匹配,则将第二个数组的值添加到第一个数组,如果不匹配,则使用数组 2 的值创建数组。
第一个数组中的主键是[created_by]
,第二个数组中的主键是[upgrade_by]
Array1 是:
Array(
[0] => Array(
[Customer] => Array(
[created_by] => 5
[amount] => 199
[name] => First Cux
)
)
[1] => Array(
[Customer] => Array(
[created_by] => 1
[amount] => 199
[name] => Last Cux
)
)
)
数组 2 是
Array(
[0] => Array(
[0] => Array(
[refund_amount] => 100
)
[Historycustomer] => Array(
[upgrade_by] => 1
[company] => First Company
)
)
[1] => Array(
[0] => Array(
[refund_amount] => 250
)
[Historycustomer] => Array(
[upgrade_by] => 3
[company] => Last Company
)
)
)
我需要这样的结果:
Array(
[0] => Array(
[Customer] => Array(
[created_by] => 5
[amount] => 199
[name] => First Cux
)
)
[1] => Array(
[Customer] => Array(
[created_by] => 1
[amount] => 199
[refund_mount]=>100
[name] => Last Cux
[company] => First Company
)
)
[2] => Array(
[Customer] => Array(
[created_by] => 3
[refund_mount]=>250
[company] => Last Company
)
)
)
第一个数组中的主键是[created_by]
,第二个数组中的主键是[upgrade_by]