Last active
December 28, 2015 10:49
-
-
Save freekrai/7489011 to your computer and use it in GitHub Desktop.
Generate UUID in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function generate_uuid() { | |
| return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', | |
| mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), | |
| mt_rand( 0, 0xffff ), | |
| mt_rand( 0, 0x0fff ) | 0x4000, | |
| mt_rand( 0, 0x3fff ) | 0x8000, | |
| mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) | |
| ); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment