Home >php教程 >php手册 >分享一个常用的生成唯一订单号方法

分享一个常用的生成唯一订单号方法

WBOY
WBOYOriginal
2016-06-07 11:35:021057browse

生成唯一订单号
    /**<br>      * 生成唯一订单号<br>      */<br>     public function build_order_no()<br>     {<br>         $no = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);<br>         //检测是否存在<br>         $db = M('Order');<br>         $info = $db->where(array('number'=>$no))->find();<br>         (!empty($info)) && $no = $this->build_order_no();<br>         return $no;<br>         <br>     }

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn