Reputation: 11255
I want to generate a random password of 15 characters that contains BOTH numbers and letters. Is there a simple way to do this?
I want to avoid a situation where I get all numbers in the password, but do not want to prefix the password with any letters.
Upvotes: 0
Views: 1268
Reputation: 11098
How about this? Generates a highly random alphanumeric password of 15 chars.
$p = substr ( md5(uniqid(rand(), true)), 0, 15);
Upvotes: 0
Reputation: 3005
you can generate the password in a loop till the length of password string you want. You can use rand() function within it to avoid the continues characters you can also use ASCII code for it with char() function
Upvotes: 0
Reputation: 822
Generate an array with a random number, a random character and 13 random chars/numbers and then use shuffle
Upvotes: 1
Reputation: 44969
You could use:
$pw = substr(md5(uniqid()), 0, 15);
I think it's very unlikely to end up with all numbers with this approach.
Upvotes: 1