1
我有兩個陣列數組1和數組2,現在我想結合或者你可以說根據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
)
)
)
好,如果你想看到。看見。如果你想製作它。然後給你的代碼努力。謝謝。 –