jblayney
asked on
create random string
Hello, I have a function which is supposed to create a random 8 character string, it works most of the time, but sometimes it creates a 7 character string.. very weird, please help...
function genRandomString() {
$length = 8;
$characters = 'ABCDEFGHJKLMNPQRSTUVWXYZ2 3456789';
$string = "";
for ($p = 0; $p < $length; $p++) {
$string .= $characters[mt_rand(0, strlen($characters))];
}
return $string;
}
function genRandomString() {
$length = 8;
$characters = 'ABCDEFGHJKLMNPQRSTUVWXYZ2
$string = "";
for ($p = 0; $p < $length; $p++) {
$string .= $characters[mt_rand(0, strlen($characters))];
}
return $string;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.