RE: [PHP] Using rand() for 10 digit numbers????

From: Date: Fri, 05 Sep 2003 17:03:04 +0000
Subject: RE: [PHP] Using rand() for 10 digit numbers????
Groups: php.general 
Request: Send a blank email to php-general+get-161784@lists.php.net to get a copy of this message
[snip] I looked at the rand() at php.net which spoke about min and max random number. So, I use rand(0,9999999999) to get a 10 digit random number but it only return an 1 digit random number that is displayed at '0'. So, I tried rand(0,9999) with 4 digit random number and got the random number. So, why does it not work with 10 digit numbers? [/snip] How may tests did you run? I just did this .... 901,476,090 1,161,662,632 1,133,163,790 116,198,549 862,072,958 160,284,836 368,780,044 1,561,820,920 1,407,692,572 1,480,574,886 473,849,932 380,642,419 167,966,462 466,661,331 1,266,542,359 160,809,301 215,539,845 85,493,351 103,799,041 950,218,662 417,076,793 1,190,550,903 658,771,070 1,388,939,508 1,357,822,101 with this.... <?php $i=25; while($i > 0){ $random=rand (0,99999999999999999); echo number_format($random, 0, '', ',')."\n"; $i--; } ?>

« previous php.general (#161784) next »