1 Answers
Try this:
function generatePassword() {
$alpha = ‘abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890’;
$password = array();
$alphaLength = strlen($alpha) – 1;
for ($i = 0; $i < 8; $i++) {
$n = rand(0, $alphaLength);
$password[] = $alpha[$n];
}
return implode($password);
}
Your Answer