Thursday, January 5, 2012

PHP: Random password with numbers and letters

function genRandomString() {
    $length = 10;
    $characters = ’0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’;
    $string = ;    

    for ($p = 0$p < $length$p++) {
        $string .= $characters[mt_rand(0strlen($characters))];
    }
    return $string;
}

No comments:

Post a Comment