PHP array_sum() Function
It calculates the sum of values in an array and returns the sum of values in an array as an integer or float.
PHP versions prior to 4.2.1 modified the passed array itself and converted strings to numbers (which often converted them to zero, depending on their value)
Parameter | Description |
---|---|
array | Required. Specifies an array |
Syntax
array_sum(array)
Example
$array=array(15,10,5);
echo array_sum($array);
Output
30
More Example
$array=array("a"=>10.2,"b"=>5,"c"=>0.9);
echo array_sum($array);
Output
16.1
Leave a Reply