Simplify code. Array not necessary.

This commit is contained in:
Nicolás A. Ortega Froysa 2022-11-17 17:29:44 +01:00
parent 0c0702fc77
commit 9ef5aee315

View File

@ -9,14 +9,13 @@ $num_dice = rand(1,10);
?>
<h1><?= $num_dice ?> dados</h1>
<?php
$rolls = [];
$max = -1;
for($i = 0; $i < $num_dice; $i++) {
$rolls[$i] = rand(1,6);
if($rolls[$i] > $max)
$max = $rolls[$i];
$roll = rand(1,6);
if($roll > $max)
$max = $roll;
?>
<img src="imgs/<?= $rolls[$i] ?>.svg" />
<img src="imgs/<?= $roll ?>.svg" />
<?php
}
?>