Generate Strong Password with PHP
$length = 8;
$characters_pool = 'luds';
$sets = array();
if (strpos($characters_pool, 'l') !== false) {
$sets[] = 'abcdefghjkmnpqrstuvwxyz';
}
if (strpos($characters_pool, 'u') !== false) {
$sets[] = 'ABCDEFGHJKMNPQRSTUVWXYZ';
}
if (strpos($characters_pool, 'd') !== false) {
$sets[] = '123456789';
}
if (strpos($characters_pool, 's') !== false) {
$sets[] = '_-=+./\",|:;!@#$%&*?';
}
$all = '';
$password = '';
foreach ($sets as $set) {
$password .= $set[array_rand(str_split($set))];
$all .= $set;
}
$all = str_split($all);
for ($i = 0; $i < $length - count($sets); $i++) {
$password .= $all[array_rand($all)];
}
echo str_shuffle($password);