PHP随机生成字符串

/**

我们提供的服务有:做网站、成都做网站、微信公众号开发、网站优化、网站认证、五台ssl等。为1000+企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的五台网站制作公司

  • 随机生成字符串
    */
    function randCode($length=5,$type=0){
    $arr = array(1 => "0123456789", 2 => "abcdefghijklmnopqrstuvwxyz", 3 => "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 4 => "~@#$%^&
    (){}[]|");
    if ($type == 0){
    array_pop($arr);
    $string = implode("", $arr);
    }elseif($type == "-1"){
    $string = implode("", $arr);
    }else{
    $string = $arr[$type];
    }
    $count = strlen($string) - 1;
    $code = '';
    for($i = 0; $i < $length; $i++){
    $code .= $string[rand(0, $count)];
    }
    return $code;
    }

分享题目:PHP随机生成字符串
网站路径:http://csdahua.cn/article/ieohgc.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流