/**
* Generate order Number
*
* Use Uniqid to get a unique, non-repeating string based on the current number of microseconds (but his first 7 bits seem to change for a long time, so do not consider the deletion) and take its 8th to 13th place. But this string contains the English alphabet, what should I do?
* Use Ord to get his ASCII code, so there's the next step: use Str_split to divide the string into arrays and use Array_map to operate (faster).
* And then return an array, KO, in a string with implode, but the character length is variable, take the previous fixed several, and then preceded by the current year and date, this method generates the order number, the world will not have much repetition.
* Of course, unless you put the server time forward, but not afraid of the tune, do not believe that he will be in the same microsecond two orders, network data transmission also points to the time, even if you are local.
*
* @return String
*/
public static function Createorderno ()
{
$date = Date (' Ymd ');
Return $date. substr (Implode (NULL, Array_map (' Ord ', Str_split (substr (),
7, 13), 1)), 0, 8);
}
Generate a non-duplicated order number (PHP)