note 60174 deleted from function.rand by felipe
| From: | felipe@php.net | Date: | Sun, 30 Dec 2007 18:44:29 +0000 |
| Subject: | note 60174 deleted from function.rand by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134435@lists.php.net to get a copy of this message | ||
Note Submitter: jeswanth at gmail dot com
----
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.