I have 2 arrays
$companyA[] = array ("QuantityOnOrder" => $quantityOnOrder, "QuantityOnHand" => $quantityOnHand, "Name" => $name);
$companyB[] = array ("QuantityOnOrder" => $quantityOnOrder, "QuantityOnHand" => $quantityOnHand, "Name" => $name);
These are multi-dimensional arrays. Let's say that company A has 3 records and company B has 10. Let's further assume that 1 of the records in companyA share the same "Name" property as a record in companyB. If that is true, then I want to take the quantityOnOrder and quantityOnHand from each array and add their values and store them in a new array.
I then want to also make sure that this new array has all of the unique values from both arrays as well. Here's an example of what the arrays may look like and what I would like the end result to look like.
CompanyA:
Array (
[0] => Array ([QuantityOnHand] => 10 [QuantityOnOrder] => 20 [Name] => LOR1)
[1] => Array ([QuantityOnHand] => 5 [QuantityOnOrder] => 6 [Name] => D23-72-P)
[2] => Array ([QuantityOnHand] => 2331 [QuantityOnOrder] => 0 [Name] => RB)
[3] => Array ([QuantityOnHand] => 3520 [QuantityOnOrder] => 0 [Name] => RTOP))
CompanyB:
Array (
[0] => Array ([QuantityOnHand] => 11 [QuantityOnOrder] => 13 [Name] => RPEN)
[1] => Array ([QuantityOnHand] => 5 [QuantityOnOrder] => 6 [Name] => D23-72-P)
[2] => Array ([QuantityOnHand] => 23 [QuantityOnOrder] => 0 [Name] => RAT)
[3] => Array ([QuantityOnHand] => 320 [QuantityOnOrder] => 0 [Name] => RBOT))
CombinedArray:
Array (
[0] => Array ([QuantityOnHand] => 10 [QuantityOnOrder] => 20 [Name] => LOR1)
[1] => Array ([QuantityOnHand] => 10 [QuantityOnOrder] => 12 [Name] => D23-72-P)
[2] => Array ([QuantityOnHand] => 2331 [QuantityOnOrder] => 0 [Name] => RB)
[3] => Array ([QuantityOnHand] => 3520 [QuantityOnOrder] => 0 [Name] => RTOP))
[4] => Array ([QuantityOnHand] => 11 [QuantityOnOrder] => 13 [Name] => RPEN)
[5] => Array ([QuantityOnHand] => 23 [QuantityOnOrder] => 0 [Name] => RAT)
[6] => Array ([QuantityOnHand] => 320 [QuantityOnOrder] => 0 [Name] => RBOT))
Notice how in the combined array I have all of the records from companyA and companyB and the records that share the same name have been combined. Hope this makes enough sense to someone. I can't figure out the best way to go about achieving the results that I'm looking for in the combined array. Any help would be much appreciated.