[PHP] array_rand() and seed

2002-07-23 Thread Naintara Jain

Using Win2K Professional Server, IIS
PHP Version 4.2.1

mt_getrandmax() returned 2147483647
I have an array of 26 characters. I want three random values from the array,
I use the following:
$rand_al = array_rand ($arralpha, 3);

I get the same characters each and every time.
The way I am handling it right now is generating random values using
mt_rand(0,25)
and using those random values as the index of the array to retrieve the
value of.

Any ideas on this?

Thanks.
Naintara




FW: [PHP] array_rand() and seed

2002-07-23 Thread Naintara Jain

First I seed the generator with

mt_srand ((double) microtime() * 100);

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
t]On Behalf Of Naintara Jain
Sent: Tuesday, July 23, 2002 6:36 PM
To: Php-General@Lists. Php. Net
Subject: [PHP] array_rand() and seed


Using Win2K Professional Server, IIS
PHP Version 4.2.1

mt_getrandmax() returned 2147483647
I have an array of 26 characters. I want three random values from the array,
I use the following:
$rand_al = array_rand ($arralpha, 3);

I get the same characters each and every time.
The way I am handling it right now is generating random values using
mt_rand(0,25)
and using those random values as the index of the array to retrieve the
value of.

Any ideas on this?

Thanks.
Naintara




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] array_rand() and seed

2002-07-23 Thread Dan Hardiker

Have you seeded the random generator?

Read up on srand and mt_srand.

- Dan

 Using Win2K Professional Server, IIS
 PHP Version 4.2.1

 mt_getrandmax() returned 2147483647
 I have an array of 26 characters. I want three random values from the
 array, I use the following:
 $rand_al = array_rand ($arralpha, 3);

 I get the same characters each and every time.
 The way I am handling it right now is generating random values using
 mt_rand(0,25)
 and using those random values as the index of the array to retrieve the
 value of.

 Any ideas on this?

 Thanks.
 Naintara


-- 
Dan Hardiker [[EMAIL PROTECTED]]
ADAM Software  Systems Engineer
First Creative Ltd



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php