php 订单号生成方法

php 订单号生成方法

function getRandomNumber($len, $chars=null)
{
if (is_null($chars)) {
$chars = "0123456789";
}
mt_srand(10000000*(double)microtime());
for ($i = 0, $str = '', $lc = strlen($chars)-1; $i < $len; $i++) {
$str .= $chars[mt_rand(0, $lc)];
}
return $str;
}

文章来自 www.96net.com.cn

posted @ 2021-07-03 14:33  学无边涯  阅读(198)  评论(0编辑  收藏  举报