PHP 生成唯一订单号

function orderNumer()
{
for ($i = 0; $i <= 701; $i++) {
$y = ($i / 26);
if ($y >= 1) {
$y = intval($y);
$yCode[] = chr($y + 64) . chr($i - $y * 26 + 65);
} else {
$yCode[] = chr($i + 65);
}
}
$orderSn = $yCode[intval(date('Y')) - 2012] . strtoupper(dechex(date('m'))) .
date('d') . substr(microtime(), 2, 5) . sprintf('%02d', rand(0, 99)) . substr(implode(null, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);;
return $orderSn;
}
posted @ 2020-07-16 10:52  温酒书生。  阅读(167)  评论(0编辑  收藏  举报