Calculate the sum of values in an array

by kalai 2009-11-07 12:18:39


<?php
$a = array(2, 4, 6, Cool
;
echo "sum(a) = " . array_sum($a) . "\n";

$b = array("a" => 1.2, "b" => 2.3, "c" => 3.4);
echo "sum(b) = " . array_sum($b) . "\n";
?>
Result
sum(a) = 20
sum(b) = 6.9

Tagged in:

1177
like
0
dislike
0
mail
flag

You must LOGIN to add comments