Closed Thread
Results 1 to 2 of 2

Thread: Random numbers

  1. #1
    Senior Member zerocool786 can only hope to improve zerocool786's Avatar
    Join Date
    Oct 2005
    Posts
    138

    Random numbers

    I have a php script that create random numbers. I want to modify, which will allow to not produce some random numbers. Basically I want it ban random # like 111111111, or 01939393. so on



    Any suggestions

  2. #2
    Member ciprian@terra-bit is an unknown quantity at this point ciprian@terra-bit's Avatar
    Join Date
    Jul 2005
    Posts
    71

    Exclamation Hi

    If all you want is just to generate random numbers, you must know the max and the min. So therefore you could use the very simple PHP function: mt_rand(); or simply rand() which doesn't need to seed the random generated number as of php 4.4.x

    So here:

    PHP Code:
    //Generating Random Numbers From 11111111 to 99999999

    $min=11111111//Number MUST be integer so we don't quote it
    $max=99999999;

    $random_number=mt_rand($min,$max);

    echo 
    $random_number
    Refresh that and you'll get several random generated numbers between those two min and max.

    However, the issue that comes into play here is the one about the random numbers repeating themselves after a certain period of time. I could do a small script that'll keep the generated numbers in mind into a mysql table or a plain file. That'll not come for free though BUT heck I think you got the idea and I'm sure you can do it now.

    Thanks
    CD
    www.o1ok.com - FREE Web Hosting, Instant account setup, Host unlimited domains INSTANTLY, INSTANT Upgrades as low as $0.04 PER MONTH ($0.5/YEAR)

Closed Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts