Create a random password using PHP. Create password in php with numbers and letters
This function creates a random password using PHP. The code snippet was taken from http://www.totallyphp.co.uk .I do not take credit for this function.
PHP Code:
<?php
function createPassword($length) {
$chars = "234567890abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$i = 0;
$password = "";
while ($i <= $length) {
$password .= $chars{mt_rand(0,strlen($chars))};
$i++;
}
return $password;
}

$password = createPassword(8);
echo "Your 8 character password is: $password";

?>
Home - Apache - Ubuntu - MySQL - PHP - Misc

The Ubuntu Counter Project - user number # 17415
Updated on: