Another question guys, I'm new to this coding environment and I've been given an assignment which is due mid September. Help me | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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.

31st Aug 2018, 6:20 AM
Tkay
2 Answers
+ 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(); ?>
31st Aug 2018, 6:29 AM
Sam Pache
Sam Pache - avatar
+ 1
Thanks you so much Sam
31st Aug 2018, 7:17 AM
Tkay