this is how I store values to array
$array[$row['name']][] = $row['from'] - $row['to'];
and here is result
Array
(
[name1] => Array
(
[0] => 1
[1] => 12
[2] => 10
)
)
Array
(
[name2] => Array
(
[0] => 0.25
[1] => 0.55
[2] => 0.35
[3] => 5
)
)
i need result like
echo $sum_of_first_array. "hours" .$name;
or:
23 hours name1
6.15 hours name2
...
You could run your values through
array_sumusingarray_map$array = array_map('array_sum', $array);All in all, something like -
See https://www.tehplayground.com/paAkQ8riS5KwFSfP
Although a better solution would be to add these as you go, like
See https://www.tehplayground.com/kA2QDWUluJ53Ueia