Interview QuestionsCategory: PHPGenerating a random password in php
princy asked 11 months ago

How to generating a random password in php?

Примите участие в новом проекте по ссылке http://bit.ly/2EMYq0D и получите более 75000 рублей. Гарантированно!

1 Answers
bestonetechnologies Staff answered 11 months ago

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

9 + 12 =