I\'m looking for a way to generate a big random number with PHP, something like:
mt_rand($lower, $upper);
The closer I\'ve
Tested and works
";
function bigRandomNumber($min,$max) {
// take the max number length
$number_length = strlen($max);
// Set the counter
$i = 1;
// Find the base and the min and max ranges
// Loop through the min to find the base number
while ($i <= $number_length) {
$sub_string = substr($min, 0, $i);
// format pattern
$format_pattern = '/'.$sub_string.'/';
if (!preg_match($format_pattern, $max)) {
$base = $sub_string;
// Set the min and max ranges
$minRange = substr($min, ($i - 1), $number_length);
$maxRange = substr($max, ($i - 1), $number_length);
// End while loop, we found the base
$i = $number_length;
}
$i++;
}
// find a random number with the min and max range
$rand = rand($minRange, $maxRange);
// add the base number to the random number
$randWithBase = $base.$rand;
return $randWithBase;
}
?>