note 35329 added to function.rand
| From: | breakzero at hotmail dot com | Date: | Wed, 27 Aug 2003 22:51:30 +0000 |
| Subject: | note 35329 added to function.rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-55190@lists.php.net to get a copy of this message | ||
Here is a Simple Funcion that Generates a Random Name String that is somewhat readable.
$Name[$x] = ucfirst (RandomName(rand(5,8)));
function RandomName( $nameLength )
{
$NameChars = 'abcdefghijklmnopqrstuvwxyz';
$Vouel = 'aeiou';
$Name = "";
for ($index = 1; $index <= $nameLength; $index++)
{
if ($index % 3 == 0)
{
$randomNumber = rand(1,strlen($Vouel));
$Name .= substr($Vouel,$randomNumber-1,1);
}else
{
$randomNumber = rand(1,strlen($NameChars));
$Name .= substr($NameChars,$randomNumber-1,1);
}
}
return $Name;
}
----
Manual Page -- http://www.php.net/manual/en/function.rand.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35329
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35329&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35329&report=yes