First Kind
Copy the Code code as follows:
Return date (' Ymd '). Str_pad (Mt_rand (1, 99999), 5, ' 0 ', str_pad_left);
The second Kind
Copy the Code code as follows:
Return date (' Ymd '). substr (Implode (NULL, Array_map (' Ord ', Str_split (substr (), 7, 13), 1)), 0, 8);
Third Kind
Generate 24-bit unique order number, format: YYYY-MMDD-HHII-SS-NNNN,NNNN-CC, where: yyyy= year, mm= month, dd= date, hh=24 format hour, ii= min, ss= second, nnnnnnnn= random number, cc= check code @date_default_timezone_set ("PRC"); while (true) { //Order Date er _date = Date (' y-m-d '); Order number Body (yyyymmddhhiissnnnnnnnn) er _id_main = Date (' Ymdhis '). Rand (10000000,99999999); Order number Body length er _id_len = strlen (er _id_main); er _id_sum = 0; for ($i =0; $i < er _id_len; $i + +) { er _id_sum + = (int) (substr (er _id_main, $i, 1)); } Unique order number (YYYYMMDDHHIISSNNNNNNNNCC) er _id = er _id_main. Str_pad ((100-er _id_sum%)% 100,2, ' 0 ', str _pad_left);
The fourth type:
Found on the Internet, find this classmate's idea is very good, Redtamo, concrete please steady past to see, I make a brief overview, the method used on the English alphabet, month and day, Unix timestamp and microsecond number, random number, the likelihood of repetition greatly reduced, or very good. The use of letters is very representative, a letter corresponding to a year, a total of 16, not many also many, hehe.
<?php $yCode = Array (' A ', ' B ', ' C ', ' D ', ' E ', ' F ', ' G ', ' H ', ' I ', ' J '); erSn = $yCode [Intval (Date (' Y '))-2011]. Strtoupper (Dechex (the date (' M '))). Date (' d '). SUBSTR (Time (),-5). SUBSTR (Microtime (), 2, 5). sprintf ('%02d ', rand (0, 99));? >
Build Effect:
Copy the Code code as follows: A422694333616096
Alas, unfortunately, the last project did not use this method, saying that there is no need to engage in such a complex,--!
The above four ways is this article to share all the content, I hope you can enjoy.