I had a task to write program that gives 20 numbers from 9 to 99 using empty array and rand function which I did...but the second step is for me to calculate and get the average number.
With functions like array_sum I can get what I want, but the idea is not to use any of array functions, just arithmetic operators
$arrNums = array();
$sum = 0;
$intTotalNum = 20;
for($i = 0; $i < $intTotalNum; $i++) {
$intRand = rand(9, 99);
$arrNums[] = $intRand;
$sum = $sum + $arrNums;
$average = $sum / count($arrNums);
}
var_dump($arrNums);
echo "<br>";
echo $average;
Code gives me an error "Unsupported operand types"