note 74351 deleted from function.rand by felipe
| From: | felipe@php.net | Date: | Sun, 30 Dec 2007 18:46:02 +0000 |
| Subject: | note 74351 deleted from function.rand by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134454@lists.php.net to get a copy of this message | ||
Note Submitter: cjaube at yahoo dot com
----
Update on Anne's function.
$pattern holds 36 characters and therefor rand should pick index numbers between 0 and 35.
Updated function:
<?php
function randomkeys($length)
{
$pattern = "1234567890abcdefghijklmnopqrstuvwxyz";
$key = $pattern{rand(0,35)};
for($i=1;$i<$length;$i++)
{
$key .= $pattern{rand(0,35)};
}
return $key;
}
?>