标签:sign mic logs lod function sprintf 变量 str substr
public function get_voucher_code($member_id = 0){ static $num = 1; $sign_arr = array(); $sign_arr[] = sprintf(‘%02d‘,mt_rand(10,99)); $sign_arr[] = sprintf(‘%03d‘, (float) microtime() * 1000); $sign_arr[] = sprintf(‘%010d‘,time() - 946656000); if($member_id){ $sign_arr[] = sprintf(‘%03d‘, (int) $member_id % 1000); } else { //自增变量 $tmpnum = 0; if ($num > 99){ $tmpnum = substr($num, -1, 2); } else { $tmpnum = $num; } $sign_arr[] = sprintf(‘%02d‘,$tmpnum); $sign_arr[] = mt_rand(1,9); } $code = implode(‘‘,$sign_arr); $num += 1; return $code; }
标签:sign mic logs lod function sprintf 变量 str substr
原文地址:http://www.cnblogs.com/mawenzhu/p/7783978.html