I try to create an array and add a value to it each time a new random number is generated.
When I generate a number, but the array stays at one value.
<?php
session_start();
$numbers = array();
$_SESSION["numbers"] = $numbers;
function getNumber() {
$getNumber = rand(1, 75);
return $getNumber;
}
?>
<?php
if(isset($_POST['submit'])) {
$numbers[] = getNumber();
array_push($_SESSION["numbers"], $numbers);
echo $numbers[0] . "<br>";
}
?>
How can I create a array which is filled each time a number is generated? Or do I need to create a db for this?
Aucun commentaire:
Enregistrer un commentaire