Generate a string with random letters and numbers in PHP (UUID)

Asked

Viewed 123 times

-3

I created a php code that generates a name with random letters and numbers (like a UUID), something like: 7a299248-fd87-4c42-b37d-a6e50a360d10. But I see that it does not perform well in relation to code execution! How can I improve performance?

$filename = substr(md5(time() . rand(1, 9999)), 0, 8)
    . "-" . substr(md5(time() . rand(1, 9999)), 0, 4)
    . "-" . substr(md5(time() . rand(1, 9999)), 0, 4)
    . "-" . substr(md5(time() . rand(1, 9999)), 0, 4)
    . "-" . substr(md5(time() . rand(1, 9999)), 0, 10);

1 answer

-3


  • Thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.