Latest web development tutorials

PHP array_sum () function

PHP Array Reference Complete PHP Array Reference

Examples

Returns an array of all the values ​​and (5 + 15 + 25):

<?php
$a=array(5,15,25);
echo array_sum($a);
?>

Running instance »

Definition and Usage

array_sum () function returns an array of all values.


grammar

array_sum( array )

参数 描述
array 必需。规定数组。

technical details

return value: Returns an array of all values.
PHP version: 4.0.4+
Update log: PHP 4.2.1 versions prior to modify the incoming array itself, which converts the string value to the value (in most cases are converted to zero, depending on the values).


More examples

Example 1

Returns an array of all the values ​​(52.2 + 13.7 + 0.9):

<?php
$a=array("a"=>52.2,"b"=>13.7,"c"=>0.9);
echo array_sum($a);
?>

Running instance »


PHP Array Reference Complete PHP Array Reference