Wylosowane liczby:
79 19 80 15 57 84 14 59 12 79 83 47 86 21 100 52 63 55 59 73
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<style>
#main {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
gap: 10px;
margin: 0;
font-family: Arial, sans-serif;
}
.section {
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
font-size: 18px;
text-align: center;
height: 28.7vh;
}
#section1 {
background-color: yellow;
color: black;
}
#section2 {
background-color: cyan;
color: black;
}
#section3 {
background-color: blue;
color: white;
grid-column: span 2;
}
#section4 {
background-color: red;
color: white;
}
#section5 {
background-color: green;
color: white;
}
.zielony {
color: green;
}
.czerwony {
color: red;
}
</style>
</head>
<body>
<div id="main">
<?php
$a = rand(1, 100);
$b = rand($a + 1, 100);
$liczby = [];
for ($i = 0; $i < 20; $i++) {
$liczby[] = rand(1, 100);
}
$c = rand(1, 100);
$c_wystapienia = 0;
foreach ($liczby as $liczba) {
if ($liczba == $c) {
$c_wystapienia++;
}
}
?>
<section id="section1" class="section">Liczba a: <?php echo $a; ?></section>
<section id="section2" class="section">Liczba b: <?php echo $b; ?></section>
<section id="section3" class="section">
<div>
<strong>Wylosowane liczby: </strong>
<?php
foreach ($liczby as $liczba) {
if ($liczba < $a) {
echo "<span class='zielony'>$liczba </span>";
} elseif ($liczba > $b) {
echo "<span class='czerwony'>$liczba </span>";
} else {
echo "$liczba ";
}
}
?>
</div>
</section>
<section id="section4" class="section">Liczba c: <?php echo $c; ?></section>
<section id="section5" class="section">Liczba <?php echo $c; ?> wystąpiła: <?php echo $c_wystapienia; ?> razy</section>
</div>
</body>
</html>