Hi,
I need to generate a lowercase alphanumeric passwrord thats 8 characters long, has anyone got a function that can do this?
No, but I can write a quick one for you. Can't guarantee the uniqueness of the password being generated.
function passgen() { srand((float) microtime() * 10000000);
//Source arrays $letters = range('a','z'); $digits = range(1,9);
//Get random items from arrays $char = array_rand($letters, 4); $num = array_rand($digits, 4);
//Combine the two random items into one array for ($i = 0; $i <4; ++$i) { $ran_char[] = $letters[$char[$i]]; $ran_num[] = $digits[$num[$i]]; } //build our password $password = array_unique(array_merge($ran_char, $ran_num));
//randomize it shuffle($password);
return join("",$password); }
echo passgen();
?>
-- Burhan Khalid phplist[at]meidomus[dot]com http://www.meidomus.com ----------------------- "Documentation is like sex: when it is good, it is very, very good; and when it is bad, it is better than nothing."
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php