I have this result:
Array ( [0] => 0, [1] => 2 ) Array ( [0] => 3, [1] => 3 ) Array ( [0] => 0, [1] => 1 ) Array ( [0] => 3, [1] => 1 ) Array ( [0] => 3, [1] => 3 )
and it comes from here:
$total = array(); $i=0; $count = 0;
foreach($dates as $d){
$total[$i] = count($value[$d]);
$i++;
}
print_r ($total); echo '<br>';
What I want to do is add $total[0] like 0+3+0+3+3 = 9 and add $total[1] like 2+3+1+1+3 = 10.
I only want back the 9 and the 10
Any ideas?
Thanks
If I am correctly understanding the question, you have no need for additional arrays inside the loop. You simply need to accumulate each array value into a different variable:
If you have an unknown number of elements, use an array to sum them up by their keys. You need an internal iterator as well. This is, incidentally a pretty common job interview question in my experience.