Re: How to get a unique series of numbers?
| From: | John Holmes | Date: | Fri, 20 Aug 2004 14:57:23 +0000 |
| Subject: | Re: How to get a unique series of numbers? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-194334@lists.php.net to get a copy of this message | ||
From: "Henri Marc" <mesmlamoi@yahoo.fr>
I want to generate a few numbers and those numbers must not be generated two times.function getnumbers($howmany, $min, $max) { $retval = array(); while(count($retval) < $howmany) { $retval[mt_rand($min,$max)] = 1; } return array_keys($retval); } Not tested, but should work. Probably want to add some checks in there so you don't end up in an infinite loop, though. :) ---John Holmes...