Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

array_sum

Description

The array_sum of Array for PHP calculate the sum of values in an array.

Syntax

array_sum ( array $array ) : number

Parameters

array

The input array.

Return

Returns the sum of values as an integer or float; 0 if the array is empty.

Examples

1

<?

$array = array(0, 1, 2);

$return = array_sum($array);

echo $return;

?>
3

2

<?

$array = array("a" => 0.1, "b" => 1.2, "c" => 2.3);

$return = array_sum($array);

echo $return;

?>
3.6

3

<?

$array = array();

$return = array_sum($array);

echo $return;

?>
0
HomeMenu