Re: random numbers

From: Date: Tue, 12 Nov 2002 09:55:28 +0000
Subject: Re: random numbers
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-123952@lists.php.net to get a copy of this message
Jon! > <?php > for ($i=1; $i<=6; $i++) > $x[] = mt_rand(1, 90); > foreach ($x as $current) > echo $current. "<br />"; > ?> Thanks for help, but your program may generate same numbers between the 5 generated numbers, hovewer I want to generate different numbers such as lottery-numbers. array_rand() is a very nice solution for this problem, other solutions with mt_rand() should be much longer. (I should care about if this random number has generated already or not) But if this is the only solution I'll do it in this way... (in this case there are a lot of useless php functions, that use random numbers adjusted to the simple srand() such as shuffle()) Tamas

« previous php.general (#123952) next »