Return to Snippet

Revision: 14602
at June 7, 2009 15:14 by Eloi


Initial Code
function randPassword() {
   $password = '';
 
   for ($x = 1; $x <= 8; $x++) {
      switch ( rand(1, 3) ) {
 
      //  Add a random digit, 0-9
      case 1:
      $password .= rand(0, 9);
      break;
 
      //  Add a random upper-case letter
      case 2:
      $password .= chr( rand(65, 90) );
      break;
 
      //  Add a random lower-case letter
      case 3:
      $password  .= chr( rand(97, 122) );
      break;
      }
   }
 
   return $password;
}

Initial URL

                                

Initial Description

                                

Initial Title
Random Password

Initial Tags
php

Initial Language
PHP