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" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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



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

Reply via email to