PHP Random string
Sunday, September 17, 2006 3:42:30 AM
Just a quick snippet which will help you to create a random number in a specific range, using PHP. PHP has a built in rand(); fuction which allows you to do this with ease. See the example below :
PHP Random Function :
rand([int_min], [int_max]);
Example :
rand(1, 999);
The code shown above will create a random number between 1 (which is the minimum) and 999 (which is the maximum).
You can make the [min] and [max] values of this function dynamic, simply by replacing the digits with your variables. You can also assign this function to a variable itself and ouput the results if needed. See the simple example below :
$min = 1; $max = 99; $random_number = rand($min, $max); echo "$random_number";
I wouldn't say that this function is really used that often, but it definitely comes in handy from time to time. Enjoy!

Update: You can use PHP uniqid() function for the same purpose. It is a built-in function and easy to use.















Satya Prakashsatya61229 # Saturday, September 5, 2009 4:09:30 AM
Unique Id each time
and
Serial no. for transaction order
Andre Nedved435andrei6 # Monday, November 22, 2010 5:13:53 PM