© 2024 fjorge. All rights reserved.
How To Generate a Random Password in PHP
Here's a quick little snippet to generate a random password in php:
function createRandomPassword($length = 7) {
$chars = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789!@#$%^&*(){}[]";
$pass = '' ;
while(strlen($pass) <= $length)
{
$pass .= $chars[mt_rand(0, strlen($chars))];
}
return $pass;
}