Getting the Sum of an Array’s Values in PHP


Use array_sum() for an easy way to sum values in an array.

Source Code

$a = array(2, 4, 6, 8);
echo "sum(a) = " . array_sum($a) . "n";
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments