This repository has been archived on 2025-10-20. You can view files and clone it, but cannot push or open issues or pull requests.
Files
2bki21/progp/24-12-4/edicer.php
2024-12-04 12:17:15 +01:00

63 lines
1.7 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>eDicer</title>
<style>
.text-bold {
font-weight: bold;
}
.w {
width: 10%;
}
.ausgabe{
margin: 12px 0;
padding: 8px;
background-color: #333;
color: white;
font-family: sans-serif;
font-weight: bold;
text-align: center;
}
.board {
text-align: center;
}
</style>
</head>
<body>
<form action="edicer.php">
<label>Wie oft soll gewürfelt werden?</label>
<input type="number" min="1" name="anzahl_wuerfel"><br>
<button type="submit">Würfel</button>
</form>
<label>(Die Ergebnisse werden sortiert wie folgt sortiert: Klein >> Groß</label>
<h1>-----------------------------</h1>
<div class="board">
<?php
$augen_array = [];
$augen = rand(1,6);
$anzahl = $_REQUEST['anzahl_wuerfel'];
// Array füllen
for ($i=1; $i<=$anzahl; $i++){
$augen = rand(1,6);
$augen_array[] = $augen;
//echo "<img width = '10%' src = '/bilder/$augen.png' alt='$augen Augen'>\n";
}
// Array ausgeben
/*echo "<pre>";
print_r($augen_array);
echo"</pre>";
*/
sort($augen_array);
for ($i=0; $i<$anzahl; $i++){
echo "<img width = '10%' src = '../bilder/$augen_array[$i].png' alt='$augen_array[$i] Augen'>\n";
}
$summe = array_sum($augen_array);
echo "<div class='ausgabe'>Die Summe der Augenzahlen beträgt $summe</div>";
echo "</div>"
?>
</body>
</html>