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