Snippet

  1. # Random Password
  2. function random_password($maxlen) {
  3. $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  4.     srand((double)microtime() * 1000000);
  5.     $i = 0;
  6.     $pass = '';
  7.  
  8.     while ($i <=$maxlen) {
  9.     $num = rand() % 62;
  10.         $tmp = substr($chars,$num,1);
  11.         $pass = $pass.$tmp;
  12.         $i++;
  13.     }
  14. return$pass;
  15. }