<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") 
{
    $name= $_POST['name'];
    $scores= array($_POST['num1'], $_POST['num2'], $_POST['num3'] );
	
    $total=0;

    for($i=0;$i<3;$i++)
    {
        echo "Score ".($i+1).": ".$scores[$i]."<br>";
        $total= $scores[$i] + $total;
    }
    $average = $total/3;
    
    echo "Average score is:".$average;

    echo "<br>";
  
    $scores_assoc = array("Score 1"=>$_POST['num1'], "Score 2"=>$_POST['num2'], "Score 3"=>$_POST['num3'] );
	foreach($scores_assoc as $x => $y)
    {
        echo "$x: $y <br>";
    }
    
} 
else 
{
	echo "Please submit the form first.";
}
?>