vegnadragon Posted February 26, 2008 Share Posted February 26, 2008 How do i rand between a selection of number instead of in between numbers? Quote Link to comment Share on other sites More sharing options...
tinker Posted February 26, 2008 Share Posted February 26, 2008 Depends upon how you store this range, here's a simple example: $l=array(0,1,2,3,4,5,0,1,2,3,0,1,0,1,0,1,0,1,0,0); srand ((double)microtime()*1000000); $randomnum = rand(0, count($l)-1); print $l[$randomnum]."<br>"; Quote Link to comment Share on other sites More sharing options...
vegnadragon Posted February 26, 2008 Author Share Posted February 26, 2008 Well, the problem is i won't know what range it will be so for example i might end up with 3, 67 and 189, and i just want one of the 3. Quote Link to comment Share on other sites More sharing options...
tinker Posted February 26, 2008 Share Posted February 26, 2008 Yeah, so you just create the list dynamically... Quote Link to comment 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.