• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Random numbers

zerocool786

Active Member
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
 
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:
//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 :D BUT heck I think you got the idea and I'm sure you can do it now.

Thanks
CD
 
Back
Top