Whats the best way to combine two arrays by matching values in the keys in each array. For example I have the two arrays:
Array
(
[id] => 1
[name] => Apple
[color] => Green
)
(
[id] => 2
[name] => Banana
[color] => Yellow
)
(
[id] => 3
[name] => Tomato
[color] => Red
)
Array
(
[product_id] => 1
[price] => 0.50
[weight] => 50
)
(
[product_id] => 2
[price] => 0.99
[weight] => 80
)
(
[product_id] => 3
[price] => 0.35
[weight] => 40
)
And I want to combine where 'id' = 'product_id' to produce:
Array
(
[id] => 1
[name] => Apple
[color] => Green
[price] => 0.50
[weight] => 50
)
(
[id] => 2
[name] => Banana
[color] => Yellow
[price] => 0.99
[weight] => 80
)
(
[id] => 3
[name] => Tomato
[color] => Red
[price] => 0.35
[weight] => 40
)