unique alphanumeric password generator function

By May 23, 2012 PHP
Alphanumeric Password

echo randomPass();

function randomPass($minChar=4, $maxChar=10, $useChar=’abcdefghijklmnopqrstu1234567890′){
   
    $numChar = rand($minChar, $maxChar);
    $numUsable = strlen($useChar) – 1;
    $string = ”;

    for($i<0; $i<$numChar; $i++){
        $rand_num = rand(0, $numUsable);
        $string .= $useChar{$rand_num};
    }
return $string;
}

Leave a Reply

− 3 = 5