How to get a unique series of numbers?

From: Date: Fri, 20 Aug 2004 12:44:09 +0000
Subject: How to get a unique series of numbers?
Groups: php.general 
Request: Send a blank email to php-general+get-194321@lists.php.net to get a copy of this message
Hello, I want to generate a few numbers and those numbers must not be generated two times. For example the user chooses to have two series of 5 numbers. then I have to generate (with MT_RAND) two series of 5 numbers. No problem for the first, then the second must be different from the first. I have to test that the third is different from the second and from the first... If one of them is equal to a previous number then I have to generate a new number. Once the first series is finished I can move to the second. It will be the same instructions. I did it using an array like: while ($number[2]==$number[1]) {//Rand again number 2... It works even if it's not nice, as far as I know how many series I must generate. But if I don't know how many series the user will want, I can't write the same lines of code hundreds of times. How would you do? Thank you so much for sharing your knowledge with me. Vous manquez d’espace pour stocker vos mails ? Yahoo! Mail vous offre GRATUITEMENT 100 Mo ! Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/ Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour dialoguer instantanément avec vos amis. A télécharger gratuitement sur http://fr.messenger.yahoo.com

« previous php.general (#194321) next »