gple Posted March 20, 2011 Share Posted March 20, 2011 how do I pull out two random integers at the same time without ever possibly choosing the same integer twice? Quote Link to comment https://forums.phpfreaks.com/topic/231214-2-random-integers/ Share on other sites More sharing options...
johnny86 Posted March 20, 2011 Share Posted March 20, 2011 Just in theory: $random1 = get_random_int(); do { $random2 = get_random_int(); } while($random1 != $random2); // Get a new random number untill they are different. Quote Link to comment https://forums.phpfreaks.com/topic/231214-2-random-integers/#findComment-1190050 Share on other sites More sharing options...
sasa Posted March 20, 2011 Share Posted March 20, 2011 <?php $a= rand(1,3); $b = rand(1, 3); while($a == $b)$b=rand(1,3); echo "$a - $b"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/231214-2-random-integers/#findComment-1190052 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.