Re: Unique Object Instance ID..?
| From: | Ross McKay | Date: | Sun, 11 Jan 2009 00:43:39 +0000 |
| Subject: | Re: Unique Object Instance ID..? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-285997@lists.php.net to get a copy of this message | ||
On Sat, 10 Jan 2009 23:31:29 +0000, Nathan Rixham wrote:
>[...]
>all I need is a completely unique id for each object instance that can
>never be repeated at any time, even in a multiserver environment (and
>without using any kind of incremented value from a db table or third
>party app)
Have you looked at uniqid() ?
http://au2.php.net/manual/en/function.uniqid.php
I use it in a couple of places, converted to a more compressed format:
$id = explode('.', uniqid(rand(), TRUE), 2);
$id = base_convert($id[0], 16, 36) . '.' . base_convert($id[1], 16, 36);
Returns stuff like this:
9xm1k6oodk8o00s4wc.50nplu
--
Ross McKay, Toronto, NSW Australia
"Let the laddie play wi the knife - he'll learn"
- The Wee Book of Calvin