note 26541 deleted from function.rand by sniper

From: Date: Tue, 23 Sep 2003 22:32:39 +0000
Subject: note 26541 deleted from function.rand by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-56999@lists.php.net to get a copy of this message
Note Submitter: clev@cleverone.com ---- Here's a function to create a random (case sensitive)password for the length you supply ... function RandomPassword( $passwordLength ) { $password = ""; for ($index = 1; $index <= $passwordLength; $index++) { // Pick random number between 1 and 62 $randomNumber = rand(1, 62); // Select random character based on mapping. if ($randomNumber < 11) $password .= Chr($randomNumber + 48 - 1); // [ 1,10] => [0,9] else if ($randomNumber < 37) $password .= Chr($randomNumber + 65 - 10); // [11,36] => [A,Z] else $password .= Chr($randomNumber + 97 - 36); // [37,62] => [a,z] } return $password; } Hope this helps. Clev

« previous php.notes (#56999) next »