1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- class Random{
- public static function uuid($whole = false){
- $id = strtolower(md5(uniqid(mt_rand(0, (double)microtime() * 1000000), true)));
-
- if($whole){
- $uuid =
- substr($id, 0, 8)."-".
- substr($id, 8, 4)."-".
- substr($id, 12, 4)."-".
- substr($id, 16, 4)."-".
- substr($id, 20, 12)
- ;
- }
- else
- $uuid = $id;
-
- return $uuid;
- }
-
- public static function num($len = 6){
- $nums = array(6, 8, 1, 7, 2, 5, 3, 9, 0, 4);
-
- if($len > 10) $len = 10;
- else if($len < 1) $len = 1;
-
- shuffle($nums);
- shuffle($nums);
-
- $num = implode("", $nums);
- $num = substr($num, 0, $len);
-
- return (string)$num;
- }
-
- public static function str(){
- $letters = array("d", "m", "q", "n", "t", "l", "s", "i", "b", "k", "u", "e", "h", "y", "x", "r", "w", "a", "p",
- "g", "j", "v", "z", "c", "o", "f");
- }
- }
|