function gen_pass($m) {
$m = intval($m);
$pass = “”;
for ($i = 0; $i < $m; $i++) {
$te = mt_rand(48, 122);
if (($te > 57 && $te 90 && $te < 97)) $te = $te – 9;
$pass .= chr($te);
}
return $pass;
}

fonte: feeds.feedburner.com