This is something i use quite a lot in many webaplis
function genpass ($length=6){
$password = ""; $possible = "0123456789bcdfghjkmnpqrstvwxyzQWERTYUIOPASDFGHJKLZXCVBNM";
$i = 0; while ($i < $length) {
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
if (!strstr($password, $char)) { $password .= $char;$i++;}
}
return $password;
}
$password = ""; $possible = "0123456789bcdfghjkmnpqrstvwxyzQWERTYUIOPASDFGHJKLZXCVBNM";
$i = 0; while ($i < $length) {
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
if (!strstr($password, $char)) { $password .= $char;$i++;}
}
return $password;
}
Comments