shamuraq Posted May 15, 2009 Share Posted May 15, 2009 Hi guys, my script is as follow: $a = rand(1,9); $b = rand(1,9); How do i make sure $b is not smaller than $a? How do i make sure they dun hv the same value? Thanx in advance... Quote Link to comment https://forums.phpfreaks.com/topic/158316-solved-logical-randomising/ Share on other sites More sharing options...
Ken2k7 Posted May 15, 2009 Share Posted May 15, 2009 $a = rand(1,9); $b = rand(0, $a -1); Quote Link to comment https://forums.phpfreaks.com/topic/158316-solved-logical-randomising/#findComment-834994 Share on other sites More sharing options...
Porl123 Posted May 15, 2009 Share Posted May 15, 2009 <?php $a = rand(1,9); $b = rand(1,9); while($b <= $a) { $b = rand(1,9); } ?> Might be long winded but that's how I'd do it Quote Link to comment https://forums.phpfreaks.com/topic/158316-solved-logical-randomising/#findComment-834996 Share on other sites More sharing options...
.josh Posted May 15, 2009 Share Posted May 15, 2009 he said b not smaller than a, and not the same value. $a = rand(0,; $b = rand($a+1,9); Quote Link to comment https://forums.phpfreaks.com/topic/158316-solved-logical-randomising/#findComment-835000 Share on other sites More sharing options...
Ken2k7 Posted May 15, 2009 Share Posted May 15, 2009 he said b not smaller than a, and not the same value. $a = rand(0,; $b = rand($a+1,9); Edited post CV. Sorry... Though, I wouldn't include a max in yours. Quote Link to comment https://forums.phpfreaks.com/topic/158316-solved-logical-randomising/#findComment-835001 Share on other sites More sharing options...
shamuraq Posted May 16, 2009 Author Share Posted May 16, 2009 thanx guys.... Actually i was hoping to see a "safe" loop method. (while) seems to slow the browser parsing... Nonetheless i truly verily appreciate the response of the pros helping slow begginer like me... Cheers... Quote Link to comment https://forums.phpfreaks.com/topic/158316-solved-logical-randomising/#findComment-835217 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.