![]() |
random number generator in php?
Hello Guys,
Please help me how can i generate random number in php? please share any related script or suggest me. Thanks for reply. |
use rand function to generate random number.
|
echo rand() . "\n";
echo rand() . "\n"; echo rand(5, 15); ?> and u will get output like this : 7771 22264 11 |
rand() simple
|
as said above, you can use rand() function.
e.g. $v = rand(1, 999999); It will assign the value of $v randomly between 1 to 999999. |
If you need different values. You can use simple function.
function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } srand(make_seed()); $randval = rand(); ?> |
Or for an array of randomized array
Quote:
|
int rand ( int $min , int $max ) function is to used to generate random number from the range.
|
All times are GMT -7. The time now is 11:11 PM. |
Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.