note 31195 added to function.rand

From: Date: Sat, 12 Apr 2003 21:48:42 +0000
Subject: note 31195 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-46554@lists.php.net to get a copy of this message
Well, since everyone else is throwing in their password generation toys :P This one will build a password out of two random words, but could be simply extended to do as many as you like. function password() { $firstwords = array('Red', 'Green', 'Yellow', 'Blue', 'Orange'); //... do lots to generate more unique passwords. $secondwords = array('Cabbage', 'Computer', 'Glass', 'Cow', 'Camal'); $firstmax = count($firstwords)-1; $secondmax = count($secondwords)-1; $password = $firstwords[rand(0, $firstmax)].$secondwords[rand(0, $secondmax); return $password; } This will generate passwords like BlueComputer, and RedCabbage, which users are more likely to remember long enough to change it to something else (or keep it... my usual password was generate along these lines by Yahoo Mail several years ago). Jon -- http://www.php.net/manual/en/function.rand.php http://master.php.net/manage/user-notes.php?action=edit+31195 http://master.php.net/manage/user-notes.php?action=delete+31195 http://master.php.net/manage/user-notes.php?action=reject+31195

« previous php.notes (#46554) next »