php随机生成不重复的字符串方法:首先创建一个php示例文件;然后使用使用时间戳作为原始字符串;接着再随机生成五个字符,并随机插入任意位置;最后生成新的字符串即可。
php随机生成不重复的字符串方法:
使用时间戳作为原始字符串,再随机生成五个字符随机插入任意位置,生成新的字符串,保证不重复function rand($len)
{
$chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$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;
}相关学习推荐:php编程(视频)