【PHP】php生成一个不重复的数字(订单号、会员号)

1、目的:利用php的do .. while 生成一个不重复的字符串或者数组,比如(订单号、会员号)

2、不废话,代码来:

$repeat_order = array();
            do{
                $ordersn = date('md') . random(8, 1);
                $repeat_order = pdo_fetch("SELECT * FROM ".tablename($tablename)." WHERE weid = '{$_W['uniacid']}' AND ordersn = :ordersn", array(':ordersn' => $ordersn));
            }while(!empty($repeat_order));

 

posted @ 2018-09-19 16:42  PHP急先锋  阅读(1080)  评论(0编辑  收藏  举报