Add dice PHP exercise.

This commit is contained in:
2022-11-17 17:12:51 +01:00
parent 55ee7e36f9
commit 0c0702fc77
7 changed files with 119 additions and 0 deletions

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>Dice</title>
</head>
<body>
<?php
$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];
?>
<img src="imgs/<?= $rolls[$i] ?>.svg" />
<?php
}
?>
<p>El valor más grande obtenido es <b><?= $max ?></b>.</p>
<p>Última modificación de esta página: <?= date('Y-m-d', filemtime(__FILE__)) ?>
</body>
</html>