1. 程式人生 > >獲取隨機的字符串

獲取隨機的字符串

pos log rand turn str class post gpo abcd

// 獲取隨機的字符串
function get_rand_char($length = 6) {
    $str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
    $strLength = 61;
    
    for($i = 0; $i < $length; $i ++) {
        $res .= $str [rand ( 0, $strLength )];
    }
    
    return $res;
}

獲取隨機的字符串