I’m generating a 5 letter uniqid in PHP this way:
$id = substr(uniqid(),0,5);
And every single time I call it, I get the value 5004b. Why is that happening?
If I remove the substr, the 5004b part stays constant while the remaining changes. Isn’t this severely reducing the entropy of the GUID being generated?
uniqid() is based on microtime(), the beginning is going to be the same for a long time.
My suggestion is that you just increment every time or something if you need a 5 digit long uniqid.