$value= array(2,5,6,8,9);
echo "Sum = ".array_sum($value);
Output
Sum = 30
This function will add all the values of the array.
$value2= array(1.5,2.3,5.5);
echo "Sum of values = ".array_sum($value2); // Output =9.3
The output of the above line would be 9.3 ( the sum of all values inside the array)
<?Php
$value= array(2,5,6,'plus2net',8,9);
echo "Sum of values = ".array_sum($value)."<br>";
?>
Output is here
Sum of values = 30
$input=array('One' =>1,'Two'=>2,'Three'=>3,'Fourth');
echo array_sum($input); // Output is 6
Output is
6
<?Php
$value= array(2,5,6,8,9);
$avg=array_sum($value) / count($value);
echo "Average value = $avg";
?>
Average value = 6
number of element present inside an array by using sizeoff()
James Aero Sudario | 10-05-2012 |
I like this one! Keep it up! :) Thank you. |