views:

92

answers:

2

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!

+2  A: 

array_sum will work for you.

$arr = array(
     'key1' => 54.3,
     65 => 10
);
$sum = array_sum($arr);
Tim Cooper
+2  A: 

array_sum http://php.net/array_sum

It sums an array - regardless of index type.

webdestroya