I have an array in the format of
Array
(
[0] => Array
(
[platform] => 1
[sales] => 244
[total] => 245971.00
[average] => 1008.08
)
[1] => Array
(
[platform] => 2
[sales] => 273
[total] => 280454.48
[average] => 1027.31
)
[2] => Array
(
[platform] => 3
[sales] => 290
[total] => 273408.00
[average] => 942.79
)
)
and another array
Array
(
[0] => Array
(
[platform] => 1
[sales] => 243
[total] => 245231.00
[average] => 1128.08
)
[1] => Array
(
[platform] => 2
[sales] => 233
[total] => 2804248
[average] => 103.31
)
[2] => Array
(
[platform] => 3
[sales] => 293
[total] => 223408.00
[average] => 942.29
)
)
How could I add these arrays together to create an array of all the values added.
For example, [sales] => 244 from the first array containing platform 11 and [sales] => 243 in the seconds array containing platform 1. I want to combine them into an array where [sales] => 487 (244 + 243) for platform 1.
Thanks in advance
Assuming the two arrays have an exact 1:1 match between their respective keys:
where $arr1 and $arr2 are your two original arrays.