Created
September 7, 2018 12:51
-
-
Save lastguest/1dc560a2bbb63d893515f89fc37f42e8 to your computer and use it in GitHub Desktop.
[PHP] Easy Unique ID Generator
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 unique_id($len = 8) { | |
$base ='ABCDEFGHKLMNOPQRSTWXYZ0123456789'; | |
$max = strlen($base)-1; $code=''; | |
mt_srand((double)microtime()*1000000); | |
while (strlen($code)<($len+1)){ | |
$code .= $base{ mt_rand(0,$max) }; | |
} return $code; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment