The array_sum() function returns the sum of all the values in the array.
PHP array_sum() Function has the following syntax.
array_sum(array)
Sum an indexed array
<?php
$a=array(5,15,25);
echo array_sum($a);
?>
The code above generates the following result.
Return the sum of all the values in the array (2.2+1.7+0.9):
<?php
$a=array("a"=>2.2,"b"=>1.7,"c"=>0.9);
echo array_sum($a);
?>
The code above generates the following result.