php 随机生成10位字符代码
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:functionrandStr($len){$chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ01234...
复制代码 代码如下:
function randStr($len)
{
$chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'; // characters to build the password from
$string='';
for(;$len>=1;$len--)
{
$position=rand()%strlen($chars);
$string.=substr($chars,$position,1);
}
return $string;
}
echo randStr(10)."<br>";