PHP script to find Highest, lowest, count and average numbers in array

phpimg

To find a highest, lowest, count and average numbers in an array

Here, we find the sample php programs to find the find he highest number in an array, similarly lowest number in an array, count of the numbers in an array and average of the numbers in an array.

<?php
$array=array(‘1′,’2′,’3′,’4’);
echo “Given array <br/>”;
$arrlength = count($array);

for($x = 0; $x < $arrlength; $x++) {
echo $array[$x];
echo “<br>”;
}echo “Highest number in an array<br/>”;
echo max($array);
echo “<br/>”;
echo “Lowest number in an array<br/>”;
echo min($array);
echo “<br/>”;
echo “Count of an array<br/>”;
echo $arrlength;
echo “<br/>”;
echo “Average of number for an array<br/>”;
$avg=array_sum($array)/count($array);
echo $avg;

?>

output

Given array
1
2
3
4
Highest number in an array
4
Lowest number in an array
1
Count of an array
4
Average of number for an array
2.5