note 58554 added to function.mt-rand

From: Date: Tue, 08 Nov 2005 04:38:48 +0000
Subject: note 58554 added to function.mt-rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-98226@lists.php.net to get a copy of this message
Yet another snippet to generate a password. <?php $acceptedChars = 'azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN0123456789'; $max = strlen($acceptedChars)-1; $password = null; for($i=0; $i < 8; $i++) { $password .= $acceptedChars{mt_rand(0, $max)}; } echo $password; ?> I have tried several ways of doing it but this simple one seems to be the fastest. ---- Manual Page -- http://www.php.net/manual/en/function.mt-rand.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58554 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58554&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58554&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58554&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58554&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58554&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58554&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58554&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58554&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#98226) next »