Originally posted by Duey
$id = md5(rand(0,9999999999));
$id = substr("$id", 15);
this would create a 15 charator id pretty much totally unique.(change the number 15 to anything less then 35) [/B]
No, that is no better than just using $id = rand(0,9999999999);
In your example there are only 10 billion possible inputs to the md5 function, so there can not be more than 10 billion possible outputs. The fact that md5 could produce more possible outputs if you had more possible inputs doesn't help you, because you don't have more possible inputs.
Also, because rand() is implemented with 32-bit integers on most systems you will be limited to at most 4.something billion possible outputs, rather than the 10 billion your 9999999999 suggests.
Even worse, a 32-bit rand() gives you 50% chance of a collision after just 216 (65536) records, due to birthday paradox.
Some comments in the PHP manual for rand() (http://www.php.net/manual/en/function.rand.php) suggest that Windows uses 16-bit integers for it. If true, that's even worse: 50% chance of a collision after just 28 (256) records.
Bottom line: Don't use rand() for generating unique numbers. It wasn't designed for that.