I searched online and found that this classmate’s idea is quite good, redtamo, please go and check it out for details. Look, let me give a brief overview. This method uses English letters, year, month, day, Unix timestamp, microseconds, and random numbers. The possibility of duplication is greatly reduced, which is still very good. The use of letters is very representative, one letter corresponds to one year, a total of 16 digits, no more, no less.
1.
Copy code The code is as follows:
$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(' d', rand(0, 99));
?>
Generation effect:
A422694333616096
2.
Copy code The code is as follows:
Function build_order_no(){
Return date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
}
echo build_order_no();
?>
Output result:
2014062356100485 2014062349535399
The above is the entire content of this article, I hope you all like it.