Wednesday, 24 September 2014

array_sum in PHP

array_sum() function calculates the total of all values from input array and returns it.

PHP array_sum() function returns a single value which is the whole of all values in the array. The input array indexed or associative.

Syntax:

array_sum(array)
array : Required. Specifies an array

Example:

<?php
$daysarr1 = array(0=>"14",1=>"23",2=>"7");
echo array_sum($daysarr1);
?>

Output:


44

0 comments:

Post a Comment