Correction de l'exercice sur les tableaux dynamiques :
<html> <head> <style> .terminal { background-color:#000 ; color:#FFF; margin:5px auto; padding:10px; width:50%; } </style> </head> <body class="terminal"> <h1> Tableau dynamique</h1> <table> <tr> <th>N</th> <th>Dé 1</th> <th>Dé 2</th> <th>Dé 3</th> <th>Somme</th> </tr> <?php $i = 1 ; /* nombre d'itérations */ do { /* tirage des trois dés */ $de1 = rand(1,6) ; $de2 = rand(1,6) ; $de3 = rand(1,6) ; $somme = $de1 + $de2 + $de3 ; echo "<tr>"; echo "<td>" . $i . "</td>"; echo "<td>" . $de1 . "</td><td>" . $de2 . "</td><td>" . $de3 . "</td>"; echo "<td>" . $somme ."</td>"; echo "</tr>"; $i = $i + 1 ; } while ( $somme < 15 ) ; ?> </table> <h1>Résultat en <?php echo $i-1 ; ?> coups !</h1> </body> </html>