On Tuesday 22 January 2002 18:52, Sam wrote:
> Hi all,
>
> Can anyone tell me why, when I run this
>
> $number = rand (1,12);
> The only number that ever appears is 5?
> Not really a random number...


You need to seed the random number generator using srand(). Best to read the 
online annotated manual as there's some useful info regarding random number 
generation.

Remember you only need to call srand() *ONCE* during the lifetime of your php 
script. Do NOT call srand() each time you want a random number.


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
Now hatred is by far the longest pleasure;
Men love in haste, but they detest at leisure.
                -- George Gordon, Lord Byron, "Don Juan"
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to