vegnadragon Posted February 26, 2008 Share Posted February 26, 2008 How do i rand between a selection of number instead of in between numbers? Link to comment https://forums.phpfreaks.com/topic/93178-random/ 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>"; Link to comment https://forums.phpfreaks.com/topic/93178-random/#findComment-477365 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. Link to comment https://forums.phpfreaks.com/topic/93178-random/#findComment-477378 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... Link to comment https://forums.phpfreaks.com/topic/93178-random/#findComment-477391 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.