> I need to be able to create files with unique names. One thought
> I had was
> to use the date functions. In windows API you can call a function that
> returns the number of milliseconds since, I think its January 1,
> 1970. That
> number would pretty much be garunteed to be unuquie (although it could be
> long, noone has to read these names).
>
> if I use the PHP gettimeofday() function and get the "usec" value, would
> this be the same thing? The manual is unclear about what the usecs is in
> reference to.
Up until PHP 4.0.5 gettimeofday under windows is unreliable as a timing
mechanism although this has now been fixed. Before PHP 4.0.5 PHP does return
some sort of contrived usec value for the time, after PHP 4.0.5 it will
return a value accurate to the nearest millisecond rather than microsecond.
This should not really affect the randomness of the function that much and
the interface from the PHP end is identical (usec value will be milliseconds
not microseconds). I would suggest using somthing like
srand((double)microtime()*1000000);
$unique_id = md5(rand(0,32000));
which is very effective for creating unique id's.
James
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]