keepAway Posted June 26, 2011 Share Posted June 26, 2011 <?php session_start(); $i=1; while($i<=26){ $i++; $nr = rand(1, 1500); echo $nr."<br />"; } ?> How could i check if a number is randomed twice before i put them into database? Quote Link to comment https://forums.phpfreaks.com/topic/240411-random-question/ Share on other sites More sharing options...
Clandestinex337 Posted June 26, 2011 Share Posted June 26, 2011 I am still really new to php aswell, but maybe a loop so if $loop <= 2 do random code? Quote Link to comment https://forums.phpfreaks.com/topic/240411-random-question/#findComment-1234862 Share on other sites More sharing options...
Pikachu2000 Posted June 26, 2011 Share Posted June 26, 2011 What do you mean by "randomed twice"? Are you trying to make sure there are no duplicate random numbers? Quote Link to comment https://forums.phpfreaks.com/topic/240411-random-question/#findComment-1234869 Share on other sites More sharing options...
colap Posted June 26, 2011 Share Posted June 26, 2011 I am still really new to php aswell, but maybe a loop so if $loop <= 2 do random code? Put all random number in array. Check if a number is there twice before storing into database. Quote Link to comment https://forums.phpfreaks.com/topic/240411-random-question/#findComment-1234873 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.