Jump to content

Help with random array numbers


reddog

Recommended Posts

Hello all, I am newbie to php programming, any suggestions or advance greatly appreciated.

 

I can't figure out how to output two array random numbers in ascending order.

 

<?php

 

$l_numbers = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,

28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47);

 

$mega = range(1, 27);

 

 

for($i = 0; $i <= 4; $i++)  {

 

 

$random1 = array_rand($l_numbers);

  echo "$random1 \n" ;

}

for($e = 1; $e <= 1; $e++) {

 

$random2 = array_rand($mega);

  echo "<p> Mega number is $random2 </p>";

}

 

echo "Winning numbers are $random1 and mega $random2";

 

?>

 

example: Winning numbers are 3,5,10,17,39 and mega 5.

Link to comment
https://forums.phpfreaks.com/topic/247631-help-with-random-array-numbers/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.