Hi ,I’ve recently started learning PHP
I am suppose to generate 4 test marks, find the average and then put that average into an array.
This is to be done for 5 students so I’ll have 5 elements in my array.
I need to display that array and the lowest value in the array.
I am unsure how to go about putting the values into the array and displaying it.
I have searched for the problem but can’t find a simple solution.
Thanks for any help.
This is my code so far.
[php]<?php
$avg=array();
$avg[] = 5;
$Average;
function Marks()
{
$T1 = rand(0,100);
$T2 = rand(0,100);
$T3 = rand(0,100);
$T4 = rand(0,100);
echo "
Test one = $T1
";echo "
Test two = $T2
";echo "
Test three = $T3
";echo "
Test four = $T4
";$Average= (($T1 + $T2 + $T3 + $T4)/4) ;
echo "
Average mark is = $Average
";echo "
-----------------------------
";$avg[$intCount] = $Average;
}
for($intCount = 0; $intCount <= 4; $intCount++)
{
Marks();
}
print_r($avg);
?>[/php]