Is there a php function that returns the sum of a row of an associative array?
If not should I just use a counter and a foreach loop?
Appreciate it!
Is there a php function that returns the sum of a row of an associative array?
If not should I just use a counter and a foreach loop?
Appreciate it!
array_sum will work for you.
$arr = array(
'key1' => 54.3,
65 => 10
);
$sum = array_sum($arr);
array_sum
http://php.net/array_sum
It sums an array - regardless of index type.