I've found something on stackoverflow
hexdec(uniqid())
You can use this
The client want the ticket id that is simple in human readable term. Something like timestamp, 12945845 . The things is, I can't use timestamp as the their could be same occurrent. UUID is great but it's too long. Well, I don't want to use ID from the database as it could grow into millions of row.
I use random_bytes and bin2hex:
bin2hex(random_bytes(5)).
The amount you give to random bytes is doubled when you pass it to bin2hex. So in this instance you'll get a ten character string.
Or, just generate a UUID and trim it to eight characters or something?
Please or to participate in this conversation.