PHP generates a unique order number, and PHP generates an order number. PHP generates a unique order number, and PHP generates an order number on the internet. I found this student had a good idea, redtamo. please take a look at the details. I will give a brief overview, this PHP generates a unique order number, and PHP generates an order number
After searching for a redtamo on the Internet, I found this student had a good idea. please take a look at the details. I will give a brief overview, this method uses English letters, year, month, and day, Unix timestamps, microseconds, and random numbers. the possibility of repetition is greatly reduced, which is quite good. The use of letters is very representative. a letter corresponds to a year, a total of 16 characters, not many.
1.
The code is as follows: <? Php
$ YCode = array ('A', 'B', 'C', 'D', 'e', 'F', 'G', 'H ', 'I', 'J ');
$ OrderSn = $ yCode [intval (date ('Y')-2011]. strtoupper (dechex (date ('M '))). date ('D '). substr (time (),-5 ). substr (microtime ()] 2, 5 ). sprintf ('% 02d', rand (0, 99 ));
?>
Effect:
A422694333616096
2.
The code is as follows: <? Php
Function build_order_no (){
Return date ('ymmd '). substr (implode (NULL, array_map ('ord ', str_split (substr (uniqid (), 7, 13), 1), 0, 8 );
}
Echo build_order_no ();
?>
Output result:
20140623561004852014062349535399
The above is all the content of this article. I hope you will like it.
I found this student's idea on the internet. redtamo. let's take a look at it. I will give a brief overview...