ddxiami

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2618|回复: 0

[文章] php生成随机唯一邀请码/优惠码固定长度

[复制链接]
发表于 2017-12-9 09:30:15 | 显示全部楼层 |阅读模式
原文地址:http://www.php1.cn/Content/php_S ... aGuDingChangDu.html


php生成随机唯一邀请码/优惠码固定长度

function make_coupon_card() {    $code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';    $rand = $code[rand(0,25)]        .strtoupper(dechex(date('m')))        .date('d').substr(time(),-5)        .substr(microtime(),2,5)        .sprintf('%02d',rand(0,99));    for(        $a = md5( $rand, true ),        $s = '0123456789ABCDEFGHIJKLMNOPQRSTUV',        $d = '',        $f = 0;        $f < 8;        $g = ord( $a[ $f ] ),        $d .= $s[ ( $g ^ ord( $a[ $f + 8 ] ) ) - $g & 0x1F ],        $f++    );    return $d;}echo make_coupon_card();


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|技术文档库 ( 闽ICP备15017263号-2 )|网站地图

GMT+8, 2025-5-18 21:10 , Processed in 0.034486 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表