PHP Password Generator


/ Published in: PHP
Save to your folder(s)

Function to simply generate a random password.


Copy this code and paste it in your HTML
  1. function generatePassword($length=8)
  2. {
  3. $chars = array_merge(range(0,9),
  4. range('a','z'),
  5. range('A','Z'),
  6. array('!','@','$','%','^','&','*')); shuffle($chars);
  7. $password = '';
  8. for($i=0; $i<8; $i++) {
  9. $password .= $chars[$i];
  10. }
  11. return $password;
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.