Jump to content

Archived

This topic is now archived and is closed to further replies.

Desdinova

Random function

Recommended Posts

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?

Share this post


Link to post
Share on other sites
[!--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]

Share this post


Link to post
Share on other sites
yeah you're right.

php.net explanes it badly. I thought rand(1,30) would create a 30char long random string.

thanks:)

Share this post


Link to post
Share on other sites
[!--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 ;-)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.