First of all, I agree with the comments. This is all the top-level code, and if you use it to make it look interesting, you should really rethink your priorities.
But, if you still need to; here is something:
function uid() { mt_srand((double)microtime()*1000000); $token = mt_rand(1, mt_getrandmax()); $uid = uniqid(md5($token), true); if($uid != false && $uid != '' && $uid != NULL) { $out = sha1($uid); return $out; } else { return false; } }
Basically, it creates a lot of random numbers to create a marker for uniqueid, and then it is sha. Maybe overhead, but you can be sure that you will never generate a double uid.
Fabian.
source share