019ebd2960d63f802796181e3bbbaa93b1229b13
[10elotto.git] / index.php
1 <?php
2 function generator($howmany = 6) {
3 $numbers = array();
4 $i = 0;
5 $max = $howmany - 1;
6
7 while ($i <= $max) {
8 $rnd_num = random_int(1, 90);
9 if (! in_array($rnd_num, $numbers)) {
10 $numbers[] = $rnd_num;
11 }
12 $i++;
13 }
14 sort($numbers);
15 return $numbers;
16 }
17 ?>
18 <!DOCTYPE html>
19 <html lang="it_IT">
20 <head>
21 <meta charset="UTF-8">
22 <title>I tuoi numeri fortunati&excl;&excl;</title>
23 <meta name="description" content="">
24 <meta name="viewport" content="width=device-width, initial-scale=1">
25
26 <!-- <link rel="stylesheet" href="assets/style/main.css"> -->
27 <!-- <link rel="icon" sizes="192x192" href="assets/img/favicon.png"> -->
28 </head>
29 <body>
30 <div id="wrapper">
31 <div id="header">
32 <header>
33 <h1>GET LUCKY&excl;</h1>
34 <h2>generatore di numeri fortunati</h2>
35 </header>
36 </div> <!-- #header -->
37
38 <div id="main" role="main">
39
40 <div id="container">
41 <div id="content">
42 <article>
43 <header>
44 <h3>Ecco i tuoi numeri</h3>
45 </header>
46 <?php
47 if (!empty($_POST["howmany"])) {
48 $num = $_POST["howmany"];
49 } else {
50 $num = 6;
51 }
52 $list = generator($num);
53 ?>
54 <div class="numbers">
55 <?php
56 $num = $num -1;
57 for ($i=0; $i <= $num ; $i++) : ?>
58 <div id="<?php echo $i; ?>"><?php echo $list[$i]; ?></div>
59 <?php endfor; ?>
60 </div> <!-- .numbers -->
61 </article>
62 </div> <!-- #content -->
63 </div> <!-- /#container -->
64
65 <aside class="menu">
66 <form action="" method="POST">
67 <input type="number" min="1" max="10" step="1" name="howmany" required>
68 <input type="submit">
69 </form>
70 </aside>
71 </div> <!-- /#main -->
72
73 <footer id ="footer">
74 </footer> <!-- #footer -->
75 </div> <!-- /#wrapper -->
76
77 </body>
78 </html>