I have a foreach loop that is running for each product in a particular product category. Inside this loop I am generating the total cost of inventory. I would like to sum arrays together that have the same key index. Is this possible? I'm not figuring out a solution.
Below is what is being output if I do a quick print_r();. This looks like it's generating three separate arrays. I would like to be able to add the sums where the keys match.
Array ( [1] => 1399.24 )
Array ( [1] => 251.72 )
Array ( [2] => 209.79 )
Desired results
Array 1 = 1650.96
Array 2 = 209.79
Any insight is appreciated.