Code:
/**
* Generate a password containing letters and numbers.
*
* @param int $length
* @param bool[optional] $mixed_case
*
* @return string
*/
function gen_pass($length, $mixed_case=true) {
$password = '';
for($i=0;$i<$length;$i++){
$letter = base_convert(rand(0,35),10,36);
$password .= ($mixed_case && rand(0,1)) ? strtoupper($letter) : $letter;
}
return $password;
}
Comment