本帖最后由 satans18 于 2013-04-02 19:33:14 编辑

解决方案 »

  1.   


    <?php
    function getRandStr($len){ 
            $chars = array("0", "1", "2","3", "4", "5", "6", "7", "8", "9"); //换成a-z,A-Z 52种
            $charsLen = count($chars) - 1; 
            shuffle($chars);
            $output = "";
            for ($i=0; $i<$len; $i++){ 
                $output .= $chars[mt_rand(0, $charsLen)]; 
            }  
            return $output;  
        }?>
      

  2.   

    function getRandStr($len){
    $str = "ABCDEFGHIJKLMNOPQRSTUVWXYZzbcdefghijklmnopqrstuvwxyz";
    $output = "";
    for ($i=0; $i<$len; $i++){ 
    $output .= $str{mt_rand(0, 52)};
    }  
    return $output;  
    }稍微修改了下,谢谢楼上两位结贴