This snippet will return a string containing random numbers. It takes 1 parameter which should be an integer. This will be the length of your string. If the parameter is not an integer, it will return false!
Example of use:
echo create_random_numbers(5);
function create_random_numbers($length)
{
if (!is_int($length)) return false;
mt_srand((double)microtime()*1000000);
$random = '';
for ($a = 0; $a < $length; $a++)
{
$random .= mt_rand(0, 9);
}
return $random;
}
Mail this!
- Comments (0)
- PingBacks (0)
- TrackBacks (0)


» Latest comments