1
I have the following array:
array (size=3)
10 =>
array (size=13)
'11/06' => int 104
'18/06' => int 145
'25/06' => int 136
'02/07' => int 135
'09/07' => int 122
'16/07' => int 133
'23/07' => int 136
'30/07' => int 139
'06/08' => int 138
'13/08' => int 140
'20/08' => int 170
'27/08' => int 162
'03/09' => int 150
'p10' =>
array (size=13)
'11/06' => float 20.04
'18/06' => float 27.94
'25/06' => float 26.2
'02/07' => float 26.01
'09/07' => float 23.51
'16/07' => float 25.63
'23/07' => float 26.2
'30/07' => float 26.78
'06/08' => float 26.59
'13/08' => float 26.97
'20/08' => float 32.76
'27/08' => float 31.21
'03/09' => float 28.9
20 =>
array (size=13)
'11/06' => int 40
'18/06' => int 41
'25/06' => int 42
'02/07' => int 39
'09/07' => int 51
'16/07' => int 73
'23/07' => int 43
'30/07' => int 61
'06/08' => int 72
'13/08' => int 61
'20/08' => int 102
'27/08' => int 63
'03/09' => int 70
and what I need to do is add up all the values where the day and month are equal in the 3 arrays.
Of the type where 06/11 will have the value of 164.04.
I tried to put something like this together, but I’m really lost on how.
$arr = array();
foreach ($teste as $key => $item) {
$arr[$key] += $item;
}
var_dump($arr)
Will all three array always have the same size, the same keys and always be sorted? I ask because I thought of a solution for arrays that meet these three criteria and another for case one or more of these criteria are not met.
– Augusto Vasques