note 16252 deleted from function.uniqid by jimw
| From: | jimw@php.net | Date: | Thu, 20 Dec 2001 20:07:54 +0000 |
| Subject: | note 16252 deleted from function.uniqid by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-23383@lists.php.net to get a copy of this message | ||
For everyone that wants a fairly simple way to use uniqid() to generate an id that is in the uuid
format:
$token = md5(uniqid(rand()));
$token_arr = preg_split("//", $token);
for($i=0; $i<33; $i++) {
$char = array_shift($token_arr);
if($i == 8 || $i == 12 || $i == 16 || $i == 20) { $newid .= "-"; }
$newid .= $char;
}
print $newid;
Have fun,
Nashoba