Here is the php code that I have. I am trying to take the average of the array and then take the avearge and the display numbers from the array that are less then the average using a foreach loop then an if statement inside the foreach loop.
<?php
$total = 0;
$avg = 0;
$n = 0;
$Random = array();
// put the data in
echo "<p>Put the numbers in<br />";
for($counter = 0; $counter <= 9; $counter++)
{
$n = rand(1, 100);
$int[$counter] = $n;
array_push($Random, $n);
echo "$n, ";
//echo "<pre>";
//print_r($Random);
//echo "</pre>";
//add the random numbers together
$total = $total + $n;
}
echo "</p>";
echo $total;
$avg = $total / count($Random);
echo "<p>" . $avg . "</p>";
// display the number of elements less then the average
foreach ($Random as $numbers)
{
$acount = 0;
$count = 0;
}
?>