Calculating the Sum of Array Values in PHP


Use array_sum() to calculate the total sum of values in an array.

Source Code

$numbers = [1, 2, 3, 4, 5];
echo "The sum is: " . array_sum($numbers);
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments