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

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

[复制链接]

86

主题

84

回帖

728

积分

管理员

积分
728
发表于 2024-5-24 14:23:06 | 显示全部楼层 |阅读模式
  1. function make_coupon_card() {
  2.     $code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  3.     $rand = $code[rand(0,25)]
  4.         .strtoupper(dechex(date('m')))
  5.         .date('d').substr(time(),-5)
  6.         .substr(microtime(),2,5)
  7.         .sprintf('%02d',rand(0,99));
  8.     for(
  9.         $a = md5( $rand, true ),
  10.         $s = '0123456789ABCDEFGHIJKLMNOPQRSTUV',
  11.         $d = '',
  12.         $f = 0;
  13.         $f <8;
  14.         $g = ord( $a[ $f ] ),
  15.         $d .= $s[ ( $g ^ ord( $a[ $f + 8 ] ) ) - $g & 0x1F ],
  16.         $f++
  17.     );
  18.     return $d;
  19. }
  20. echo make_coupon_card();
复制代码


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

本版积分规则

Archiver|手机版|小黑屋|Discuz! X

GMT+8, 2025-12-6 12:38 , Processed in 0.080048 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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