- substr: documentation ( source)
- str_shuffle: documentation ( source)
<?php
function GeneratePassword($length, $map)
{
$result = '';
for ($i = 0; $i < $length; ++$i) {
$result .= substr(str_shuffle($map), 0, 1);
}
return $result;
}
echo GeneratePassword(7,'abczxc012394');