$mt_rand = mt_rand(1000000000, 9999999999); echo $mt_rand;
$unique_id = uniqid(); echo $unique_id;
uniqid( prefix, more_entropy )
Can be useful, for instance, if you generate identifiers simultaneously on several hosts that might happen to generate the identifier at the same microsecond.
With an empty prefix, the returned string will be 13 characters long. If more_entropy is TRUE, it will be 23 characters.
If set to TRUE, uniqid() will add additional entropy (using the combined linear congruential generator) at the end of the return value, which increases the likelihood that the result will be unique.
$mt_rand = mt_rand(1000000000, 9999999999); $timestamp = time(); $temp = $mt_rand + $timestamp; $temp2= substr($tmp, 0,10); echo $temp2;