[thelist] srand in php

Andrew Forsberg andrew at thepander.co.nz
Tue Oct 23 17:31:00 CDT 2001


At 6:10 PM -0400 23/10/01, noah wrote:
>I was just curious as to why the first digit of a 10 digit number was always 1

Me too.

>Thanks for that

You're quite welcome! It's fun to find problems on evolt to solve -- 
more intriguing than the pile o' work that's sitting here next to me 
:)


At 5:58 PM -0400 23/10/01, Jay Greenspan wrote:
>I can think of a couple of hacky ways to get a random number that's 
>10 digits, but I'd like to see what other list members will come up 
>with.

Please put me out of my misery and let me know how you (or other 
evolters) would do it. Would this be ok? Or is it a bit too 
round-about?

mt_srand((double)microtime()*1000000);
$key_a = 100000 * mt_rand(10000,99999);
$key_b = mt_rand(10000,99999);
$key = floor ($key_a + $key_b);

Cheers
Andrew

-- 
Andrew Forsberg
---
uberNET - http://uber.net.nz/
the pander - http://thepander.co.nz/




More information about the thelist mailing list