vendredi 26 juin 2015

Generating random string of fixed length [duplicate]

This question already has an answer here:

I want to generate a 6 character long unique key in php in which first 3 should be alphabets and next 3 should be digits.

I know about the uniqid() function but it generates 13 characters long key and also it wont fit in my requirement as I need first 3 characters as alphabets and next 3 as numbers.

Any way in which I can modify uniqid() to fit in my requirements?

I also dont want any collisions because if that happens my whole database will be wasted that is why I can't use rand function because it is very likely that I will get collisions




Aucun commentaire:

Enregistrer un commentaire