array_sum
Summarize all values in an array
array_sum()
function returns the sum of all values in the array.
If all values are integers, an integer value is returned. If one or more of the values are floating points, the floating point number is returned.
Returns the sum of all values in the array (5+15+25):
<?php $a = array ( 5 , 15 , 25 ) ; echo array_sum ( $a ) ; ?>
Try it yourself
Returns the sum of all values in the array (52.2+13.7+0.9):
<?php $a = array ( "a" => 52.2 , "b" => 13.7 , "c" => 0.9 ) ; echo array_sum ( $a ) ; ?>
Try it yourself
array_sum ( array )
parameter | describe |
---|---|
array | Required. Specify array. |