tdphp/td1_2/11.php
2023-03-22 00:13:04 -07:00

39 lines
No EOL
550 B
PHP

<?php
$tableau = array(
"jean" => 14,
"claude" => 13,
"david" => 18,
"maxime" => 1,
);
$moyenne = 0;
foreach ($tableau as $prenom => $note) {
echo "$prenom: $note<br/>";
$moyenne += $note;
}
$moyenne = $moyenne / count($tableau);
echo "<p><strong>Moyenne :</strong> $moyenne";
// Modification des notes
foreach ($tableau as $prenom => $note) {
if ($prenom == "jean") {
continue;
}
$tableau[$prenom] = $note - 2;
}
echo "<hr><h3>Nouvelles notes</h3>";
?>
<pre>
<?php
print_r($tableau);
?>
</pre>