tdphp/11.php

39 lines
550 B
PHP
Raw Normal View History

2023-03-06 15:21:44 +01:00
<?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>