Looking for it on the internet, found this classmate's idea is very good, Redtamo, concrete Please steady past look, I make a brief overview, the method used in English alphabet, years, Unix time stamp and microsecond number, random number, the likelihood of duplication is greatly reduced, or very good. The use of letters is very representative, a letter corresponding to a year, a total of 16, not many and many.
1.
Copy Code code as follows:
<?php
$yCode = Array (' A ', ' B ', ' C ', ' D ', ' E ', ' F ', ' G ', ' H ', ' I ', ' J ');
$orderSn = $yCode [Intval (Date (' Y ')]-2011]. Strtoupper (Date (' M ')) (Dechex). Date (' d '). SUBSTR (Time (),-5). SUBSTR (Microtime ()] 2, 5). sprintf ('%02d ', rand (0, 99));
?>
Build Effect:
2.
Copy Code code as follows:
<?php
function Build_order_no () {
Return date (' Ymd '). substr (Implode (NULL, Array_map (' Ord ', Str_split (substr (), 7, 13), 1)), 0, 8);
}
Echo Build_order_no ();
?>
Output results:
2014062356100485
2014062349535399
The above mentioned is the entire content of this article, I hope you can enjoy.