使用时间戳作为原始字符串,再随机生成五个字符随机插入任意位置,生成新的字符串,保证不重复
1 function rand($len) 2 { 3 $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'; 4 $string=time(); 5 for(;$len>=1;$len--) 6 { 7 $position=rand()%strlen($chars); 8 $position2=rand()%strlen($string); 9 $string=substr_replace($string,substr($chars,$position,1),$position2,0); 10 } 11 return $string; 12 }