PHP generates a unique order number, PHP generates order number _php tutorial

Source: Internet
Author: User

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.