Desdinova Posted April 6, 2006 Share Posted April 6, 2006 This doesn't seem possible with rand();what I need is, I have say 32 options. I want to select a number between 1 and 32. How should I do this? Link to comment https://forums.phpfreaks.com/topic/6733-random-function/ Share on other sites More sharing options...
obsidian Posted April 6, 2006 Share Posted April 6, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]If you want a random number between 5 and 15 (inclusive), for example, use rand (5, 15).[/quote]with that in mind, for your solution, you simply need to do the following:[code]$i = rand(1, 32);[/code] Link to comment https://forums.phpfreaks.com/topic/6733-random-function/#findComment-24471 Share on other sites More sharing options...
Desdinova Posted April 6, 2006 Author Share Posted April 6, 2006 yeah you're right.php.net explanes it badly. I thought rand(1,30) would create a 30char long random string.thanks:) Link to comment https://forums.phpfreaks.com/topic/6733-random-function/#findComment-24474 Share on other sites More sharing options...
obsidian Posted April 6, 2006 Share Posted April 6, 2006 [!--quoteo(post=362241:date=Apr 6 2006, 10:55 AM:name=Desdinova)--][div class=\'quotetop\']QUOTE(Desdinova @ Apr 6 2006, 10:55 AM) [snapback]362241[/snapback][/div][div class=\'quotemain\'][!--quotec--]yeah you're right.php.net explanes it badly. I thought rand(1,30) would create a 30char long random string.thanks:)[/quote]the manual definitely can be difficult to understand at times... that's why we're here ;-) Link to comment https://forums.phpfreaks.com/topic/6733-random-function/#findComment-24475 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.