我在下面的代码中的列表行上得到一个未定义的偏移量。任何想法为什么?即使我收到偏移错误,仍然会生成密码
function generatePassword($length=6,$level=2){
list($usec, $sec) = explode(' ', microtime(true));
srand((float) $sec + ((float) $usec * 100000));
$validchars[1] = "23456789abcdefghjkmnpqrstuvwxyz";
$validchars[2] = "23456789abcdefghjkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ";
$validchars[3] = "23456789_!@#$%&*()-= /abcdefghjkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ_!@#$%&*()-= /";
$password = "";
$counter = 0;
while ($counter < $length) {
$actChar = substr($validchars[$level], rand(0, strlen($validchars[$level])-1), 1);
// All character must be different
if (!strstr($password, $actChar)) {
$password .= $actChar;
$counter++ ;
}
}
re
转$密码;
}