我有两个数组 Array1 和 Array2 ,现在我想要结合或者你可以说根据product_option_id
在每个数组中将这些数组合并为一个如果product_option_id
相同,则将第二个数组数据推入一个。
我的第一个数组是:
Array
(
[0] => Array
(
[DispensaryInventory] => Array
(
[id] => 21
[dispensary_id] => 18
[product_id] => 7
[product_option_id] => 1
)
)
[1] => Array
(
[DispensaryInventory] => Array
(
[id] => 22
[dispensary_id] => 18
[product_id] => 7
[product_option_id] => 2
)
)
[2] => Array
(
[DispensaryInventory] => Array
(
[id] => 23
[dispensary_id] => 18
[product_id] => 7
[product_option_id] => 3
)
)
[3] => Array
(
[DispensaryInventory] => Array
(
[id] => 24
[dispensary_id] => 18
[product_id] => 7
[product_option_id] => 4
)
)
[4] => Array
(
[DispensaryInventory] => Array
(
[id] => 25
[dispensary_id] => 18
[product_id] => 7
[product_option_id] => 5
)
)
)
和第二个数组是
Array
(
[0] => Array
(
[DriverInventory] => Array
(
[id] => 21
[driver_id] => 10
[dispensary_inventory_id] => 12
[product_id] => 7
[product_option_id] => 2
)
[Mydata] => Array
(
[price]= 2545
)
)
[1] => Array
(
[DriverInventory] => Array
(
[id] => 22
[driver_id] => 10
[dispensary_inventory_id] => 13
[product_id] => 7
[product_option_id] => 3
[quantity] => 16
)
[Mydata] => Array
(
[price]= 15987
)
)
[2] => Array
(
[DriverInventory] => Array
(
[id] => 23
[driver_id] => 10
[dispensary_inventory_id] => 14
[product_id] => 7
[product_option_id] => 4
[quantity] => 20
)
[Mydata] => Array
(
[price]= 96744
)
)
[3] => Array
(
[DriverInventory] => Array
(
[id] => 24
[driver_id] => 10
[dispensary_inventory_id] => 15
[product_id] => 7
[product_option_id] => 5
[quantity] => 45
)
[Mydata] => Array
(
[price]= 97455
)
)
)
最后我希望成为
的结果Array
(
[0] => Array
(
[DispensaryInventory] => Array
(
[id] => 21
[dispensary_id] => 18
[product_id] => 7
[product_option_id] => 1
)
)
[1] => Array
(
[DispensaryInventory] => Array
(
[id] => 22
[dispensary_id] => 18
[product_id] => 7
[product_option_id] => 2
)
[Mydata] => Array
(
[price]= 2545
)
)
[2] => Array
(
[DispensaryInventory] => Array
(
[id] => 23
[dispensary_id] => 18
[product_id] => 7
[product_option_id] => 3
)
[Mydata] => Array
(
[price]= 15987
)
)
[3] => Array
(
[DispensaryInventory] => Array
(
[id] => 24
[dispensary_id] => 18
[product_id] => 7
[product_option_id] => 4
)
[Mydata] => Array
(
[price]= 96744
)
)
[4] => Array
(
[DispensaryInventory] => Array
(
[id] => 25
[dispensary_id] => 18
[product_id] => 7
[product_option_id] => 5
)
[Mydata] => Array
(
[price]= 97455
)
)
)
答案 0 :(得分:1)
试试这个。
()