php批量生成不重复的虚拟卡卡号和密码
日期:2020-09-26
网站开发需要一组虚拟的消费卡,卡号和密码不重复,且具有随机特性
<?php $numLen = 16; //必须16以上,要不然重复的可能性很高 $pwdLen = 10; $c = 1000; //生成1000组卡号密码 $sNumArr = range(0, 9); $sPwdArr = array_merge($sNumArr, range('A', 'Z')); $cards = array(); for ($x = 0; $x < $c; $x++) { $tempNumStr = array(); for ($i = 0; $i < $numLen; $i++) { $tempNumStr[]=array_rand($sNumArr); } $tempPwdStr = array(); for ($i = 0; $i < $pwdLen; $i++) { $tempPwdStr[]=$sPwdArr[array_rand($sPwdArr)]; } $cards[$x]['no'] = implode('', $tempNumStr); $cards[$x]['pwd'] = implode('', $tempPwdStr); } array_unique($cards); var_dump($cards); ?>
本文原创地址:https://www.ecshopok.com/article-647.html
版权所有 © 转载时必须以链接形式注明出处!
觉得本文对您有用,想收藏下来!方法很简单:请点击-〉
我们一直坚持白天工作、晚上熬夜更新资源,付出了巨大的精力和时间,其中的辛酸难以言述。
下一篇:php限制页面刷新速度防止恶意刷新攻击代码 上一篇:最新Paypal获取API用户名,密码,签名用于外贸网站收款教程
暂无评论,来发表一个吧