note 65913 deleted from function.microtime by bjori
| From: | bjori@php.net | Date: | Wed, 10 May 2006 07:23:16 +0000 |
| Subject: | note 65913 deleted from function.microtime by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-111023@lists.php.net to get a copy of this message | ||
Note Submitter: nicko2k at ennkayohh dot net
----
In RE: Eric Pecoraro's comment below:
I've always found a much much simpler (and faster imho) way of doing this is just stamping
posix_getpid() onto the back of microtime() and md5()'ing the whole thing, then use substr to
shorten to the required length, eg:
<?php
// punch out a 20-byte random ID
print substr(md5(microtime() . posix_getpid()), 0, 20);
?>
I've never had a duplicate ID generated by this, and it's been in some pretty high-demand
fast loops.