$matieres = array("Français", "Mathématiques", "Physique");
$notes = array( 12, 14, 16);
$coefficients = array(2, 6, 4);
$somme_notes = 0;
$somme_coefs = 0;
for ($i = 0; $i < count($notes); ++$i) {
echo "
". $matieres[$i] ." | ";
echo "". $notes[$i] ." | ";
echo "". $coefficients[$i] ." |
";
$somme_notes += $notes[$i] * $coefficients[$i];
$somme_coefs += $coefficients[$i];
}
$moyenne = $somme_notes / $somme_coefs;
$moyenne = round($moyenne * 100) / 100.0;
echo "Total : | $moyenne |
";