Re: Random Numbers Script

From: Date: Tue, 29 Oct 2002 08:52:44 +0000
Subject: Re: Random Numbers Script
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-16609@lists.php.net to get a copy of this message
Generating random numbers is quite easy in php. I suggest using rand( ). Simply put your upper limits and lower limits in, then it randomly chooses a number inbetween. EG: rand( 1, 9 ) generates a random number between 1 and 9. If you want to be able to control the length, then use rand however many times its needed $LengthOfRandom = "4"; WHILE ( $LengthOfRandom > 0 ) { $RandomNumber .= rand( 0,9 ); //The .= means it will add the value on the right on to what already excists on the left $LengthOfRandom = $LengthOfRandom - 1; } print $LengthOfRandom; would output random numbers like below 1220 8273 For more infomation, take a look at http://www.php.net/manual/en/function.rand.php Hope this helps Stephen ----- Original Message ----- From: "Raheel Hussain" <raheelphp@yahoo.com> To: <php-windows@lists.php.net> Sent: Tuesday, October 29, 2002 7:51 AM Subject: [PHP-WIN] Random Numbers Script > I want to generate three to Six digit long random numbers > with the foloowing input > > 1 - length in digits : 4 > 2 - How many numbers do you want to generate : 4 > > and then the script runs and generate the following > > 1220 > 1282 > 7324 > 3343 > > simillarly > > 1 - length in digits : 6 > 2 - How many numbers do you want to generate : 4 > > and then the script runs and generate the following > > 321220 > 321282 > 447324 > 643343 > > etc. > > but i cant get to any spot for this , this may be a cheap question for u guys but plz help > > regards > > > > --------------------------------- > Do you Yahoo!? > HotJobs - Search new jobs daily now

« previous php.windows (#16609) next »