Chris wrote:
Jasper Bryant-Greene wrote:

$unique_id = sha1( uniqid( mt_rand(), true ) );

That unique ID will be based on the current time in microseconds prefixed by a random number generated by the Mersenne Twister. That is *extremely* unlikely to duplicate, even at the same microsecond.

Ok, thanks, That looks like it will work for me.

Any particular reason why you used sha1() in there?

Because if you take a look at the output of uniqid( mt_rand(), true ) you will see that it changes in length each time it is run, whereas after running through sha1() it is always 40 characters

I just find that the output of sha1() looks tidier anyway.

--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to