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? 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. 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"; ?> Link to comment https://forums.phpfreaks.com/topic/231214-2-random-integers/#findComment-1190052 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.