Created
October 1, 2014 12:01
-
-
Save vzabaznov/4eb37365ce116fff04af to your computer and use it in GitHub Desktop.
generate unique number(not id)
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
| public static function generateUniqueNumber($len = 9) | |
| { | |
| $numbers = '0123456789'; | |
| $result = mb_substr($numbers, rand(0, $len),1); | |
| for ($i = 1; $i < $len; $i++) { | |
| $result .= mb_substr($numbers, rand(0, $len),1); | |
| } | |
| return $result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment