php 随机生成10位字符

来源:互联网 发布:udacity网络爬虫 编辑:程序博客网 时间:2024/06/11 14:49

php 随机生成10位字符

 

 

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>";

原创粉丝点击