一、

  网站开发需要一组虚拟的消费卡,卡号和密码不重复,且具有随机特性

 1 <?php
 2 $numLen=16; //必须16以上 要不然重复的可能性很高
 3 $pwdLen=10;
 4 $c=1000;//生成1000组卡号密码
 5 $sNumArr=range(0,9);
 6 $sPwdArr=array_merge($sNumArr,range('A','Z'));
 7 
 8 $cards=array();
 9 for($x=0;$x< $c;$x++){
10   $tempNumStr=array();
11   for($i=0;$i< $numLen;$i++){
12     $tempNumStr[]=array_rand($sNumArr);
13   }
14   $tempPwdStr=array();
15   for($i=0;$i< $pwdLen;$i++){
16     $tempPwdStr[]=$sPwdArr[array_rand($sPwdArr)];    
17   }
18   $cards[$x]['no']=implode('',$tempNumStr);
19   $cards[$x]['pwd']=implode('',$tempPwdStr);
20 }
21 array_unique($cards);
22 var_dump($cards);
23 ?>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-27
  • 2021-07-25
  • 2021-09-02
  • 2021-11-11
  • 2021-12-09
猜你喜欢
  • 2021-10-07
  • 2021-08-19
  • 2022-12-23
  • 2021-04-11
  • 2021-11-13
  • 2022-12-23
  • 2021-12-11
相关资源
相似解决方案