how can create a unique tracking code?
What is your suggestion?
The number of characters not more than 10 and use only of number .
Please call example powerful...
how can create a unique tracking code?
What is your suggestion?
The number of characters not more than 10 and use only of number .
Please call example powerful...
If you're willing to allow for a few more characters, and let your number be a hex number, the uniqid function will be useful to you
How about using time();?? It will give exactly 10digits and will be unique forever with a difference of microseconds:)
Because of maximum random number limits, you might use something like this:
$number = mt_rand(10000,99999).mt_rand(10000,99999);
Or use for
loop as @JK posted.
Then, you might check uniquiness of the number, and, if not unique, generate new...
$random = "";
for($i = 0; $i < 10; $i++)
$random .= mt_rand(0, 9);
However if you want something more powerful you should consider using characters as well:
$random = substr(base64_encode(sha1(mt_rand())), 0, 10);