PHP generates a unique order number, PHP generates the order number
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 representative, a letter corresponding to a year, a total of 16, not many and many.
1.
Copy the Code code as follows: <?php
$yCode = Array (' A ', ' B ', ' C ', ' D ', ' E ', ' F ', ' G ', ' H ', ' I ', ' J ');
$orderSn = $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:
A422694333616096
2.
Copy the 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 Result:
20140623561004852014062349535399
The above mentioned is the whole content of this article, I hope you can like.
http://www.bkjia.com/PHPjc/1027048.html www.bkjia.com true http://www.bkjia.com/PHPjc/1027048.html techarticle PHP generated a unique order number, PHP generated order number on the Internet to find some, found that the classmate's idea is very good, Redtamo, concrete please steady past to see, I make a brief overview, the party ...