[thelist] srand in php

noah noah at tookish.net
Tue Oct 23 13:57:23 CDT 2001


I'm generating a random number using php - I found the information about 
how to do it in the php manual and at phpbuilder. The random number is 10 
digits long, and is generated like this:

mt_srand((double)microtime()*1000000);
$key = mt_rand(1000000000,9999999999);

I'm just wondering if anyone can offer any insight on why the random number 
always begins with 1. The next nine digits appear to be random, but the 40 
times or so that I've run this, the first digit has always been 1.

Thanks,
Noah





More information about the thelist mailing list