note 27756 added to function.rand

From: Date: Tue, 17 Dec 2002 19:42:53 +0000
Subject: note 27756 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-41032@lists.php.net to get a copy of this message
correct RandomPassword function : function RandomPassword( $passwordLength ) { $password = ""; for ($index = 1; $index <= $passwordLength; $index++) { // Pick random number between 1 and 61 $randomNumber = rand(1, 61); // Select random character based on mapping. if ($randomNumber < 11) $password .= Chr($randomNumber + 48 - 1); // [ 1,10] => [0,9] else if ($randomNumber < 36) $password .= Chr($randomNumber + 65 - 10); // [11,36] => [A,Z] else $password .= Chr($randomNumber + 97 - 36); // [37,62] => [a,z] } return $password; } -- http://www.php.net/manual/en/function.rand.php http://master.php.net/manage/user-notes.php?action=edit+27756 http://master.php.net/manage/user-notes.php?action=delete+27756 http://master.php.net/manage/user-notes.php?action=reject+27756

« previous php.notes (#41032) next »