Forum Moderators: coopster

Message Too Old, No Replies

which one is better?

         

PHPycho

4:44 am on Mar 11, 2010 (gmt 0)

10+ Year Member



Which one do you prefer among the two?
function genRandomNo($length = 5){ $string = substr(md5(uniqid(rand(), true)), 0, $length); return $string; }
Vs
function genRandomNo($length = 5){ $string = substr(md5(microtime() * mktime()), 0, $length); return $string; }

also you can suggest alternatives.

Thanks

[edited by: eelixduppy at 2:32 pm (utc) on Mar 11, 2010]
[edit reason] fixed formatting [/edit]

Readie

8:10 am on Mar 11, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If this is supposed to be a unique identity - the best thing you can do is

$someVariableName = date(YmdHisu);

(Bear in mind the 'u' will do nothing but stick several 0's on the end if you are not running PHP 5.3)