Question

I would like to create a unique id in php.I used uniqid() but microtime is not helping because the function is inside a loop and a set of consecutive results are exactly the same!! So i am wondering if i can use nano time.In linux it possible using system() function. Is there any such ways in windows through which I can get nano time in PHP?

Was it helpful?

Solution

my idea is to add rand() as a prefix like so:

md5(uniqid(rand(), true));

the md5() is just a wrapper to make them pretty, you can remove it or format the results in other way depending on your need.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top