note 60174 added to function.rand

From: Date: Wed, 28 Dec 2005 18:49:36 +0000
Subject: note 60174 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-100879@lists.php.net to get a copy of this message
Hi all, I wish that following code might be usefull for you. Rand() can be used to generate unique userfriendly codes. For example if you want to give each user a code that can be easily rememberd. Rand() surprisingly generates userfriendly codes when used like this, <?php $num = rand(0, 9); $num1 = rand(0, 9); $num2 = rand(0, 9); $num3 = rand(0, 9); $num4 = rand(0, 9); $num5 = rand(0, 9); $code = $num . $num1 . $num2 . $num3 . $num4 . $num5; echo "$code"; ?> When you run this code, you can see the generated number is easiy to remember. ---- Manual Page -- http://www.php.net/manual/en/function.rand.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60174 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60174&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60174&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60174&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60174&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60174&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60174&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60174&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60174&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#100879) next »