note 26662 deleted from function.rand by maxim

From: Date: Fri, 08 Nov 2002 14:12:40 +0000
Subject: note 26662 deleted from function.rand by maxim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-39165@lists.php.net to get a copy of this message
Generates a password with the desired length ($size) function random_pass($size) { $letters = array ('a','b','c','d','e','f', 'g','h','i','j','k','l', 'm','n','o','p','q','r', 's','t','u','v','w','x', 'y','z','0','1','2','3', '4','5','6','7','8','9'); $uppercase = array('0','1'); for ($i = 0; $i < $size; $i++) { srand ((double) microtime() * 10000000); $char = $letters[array_rand ($letters)]; //selects random letter srand ((double) microtime() * 10000000); $upper = array_rand($uppercase); //randomly selects if letter is upper or no if($upper == '1') $string[$i] = strtoupper($char); else $string[$i] = $char; } $random_pass = implode("", $string); return $random_pass; }

« previous php.notes (#39165) next »