Array1 ( [a] => 1 [b] => 2 [c] => 7 [d] => )
Array2 ( [a] => 2 [x] => 4 [y] => )
I tried these to add the two arrays to get a new array where matching keys values are added. The final array would be:
Array3 ( [a] => 3 [b] => 2 [c] => 7 [d] => [x] => 4 [y] => )
I am looking at, but can't get the final array to display all keys:
foreach($array1 as $key => $val)
{
$final_value = $val + $array2[$key];
$final_array[] = array($key=>$final_value);
}
Is that I have, but does not work.
I also looked at Jonah's suggestion at: Merge 2 Arrays and Sum the Values (Numeric Keys)