PHP array_sum() Function

PHP array_sum() Function returns the sum all values of array. An array_sum() function is built-in function in PHP.

Syntax :

array_sum(array $array);

Parameter,

$array : Required. It is input array.

 Return : It returns addition of values in an array. The sum of values are an integer or float.

Let's see below example to understand php array_sum() Function in details.

Example :

<?php
$array = array(4,6,8,2,9,1);
echo "<br><br>array_sum function returns sum of all value in array.<br>";
$val = array_sum($array);
echo "<br>Sum is ".$val;

$array = array(33.4,3.2,8.7,45.3);
echo "<br><br>array_sum function returns sum of all value in array.<br>";
$val = array_sum($array);
echo "<br>Sum is ".$val;
?>

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

28728