好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

php如何随机生成不重复的字符串

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编程(视频)

以上就是php如何随机生成不重复的字符串的详细内容!

查看更多关于php如何随机生成不重复的字符串的详细内容...

  阅读:45次