推荐:《PHP视频教程》
php生成不重复随机字符串
使用时间戳作为原始字符串,再随机生成五个字符随机插入任意位置,生成新的字符串,保证不重复
function rand($len)
{
$chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567abcdefghijklmnopqrstuvwxyz';
$string=time();
for(;$len>=1;$len--)
{
$position=rand()%strlen($chars);
$position2=rand()%strlen($string);
$string=substr_replace($string,substr($chars,$position,1),$position2,0);
}
return $string;
}该方法适用于所有型号的电脑。
Copyright © 2019- wenfangsibao.com.cn 版权所有
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务