Add dice PHP exercise.
This commit is contained in:
26
2/IAW/exercises/php/dice.php
Normal file
26
2/IAW/exercises/php/dice.php
Normal 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>
|
Reference in New Issue
Block a user