--On Saturday, September 20, 2003 20:58 +0100 dan <[EMAIL PROTECTED]> wrote:


how is it possible to get a random number between x and y? in know
int(rand(10)) returns an integer between 0 and 9, but how do i get
it so that i can get a random integer say between 5 and 10
inclusive?

How about:


$num = int(rand(6)) + 5;

or generalized:

$num = int(rand(($max - $min) + 1)) + $min;

Daniel T. Staal

---------------------------------------------------------------
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to