array_sum in php example

The array_sum() function calculates the sum value for the given array values.

Syntax:

array_sum($array);

Program:

<?php
$number=array(10,20,5);
print_r($number);
$total=array_sum($number); 
//array_sum() calculates the sum values for $number array values.
echo "Sum of given array  is\t";
print_r($total);
?>

 

Output:

array_sum output

 

 

Thanks for reading this post………………!!!

Leave a Reply