0
Another question guys, I'm new to this coding environment and I've been given an assignment which is due mid September. Help me
Write a PHP and Html program which create a function that stores the numbers 1 to 49 in an array. Six random numbers must be outputted when the function is called.
2 Réponses
+ 1
<?php
function storeNumber(){
$array = array();
$randomNumbersInArray = array();
for($i = 1; $i < 50; $i++){
$array[] = $i;
}
for($i = 0; $i < 6; $i++){
$rand = rand(1, 49);
$randomNumbersInArray[] = $array[$rand]; //Output as new array
echo $array[$rand]; //Output as html
}
return $randomNumbersInArray;
}
//Output 6 numbers between 1 and 49 as html, keep it in an array
$arrayWithNumbers = storeNumbers();
?>
+ 1
Thanks you so much Sam