note 18409 deleted from function.uniqid by irc-html
| From: | irc-html@php.net | Date: | Mon, 21 Jan 2002 23:50:49 +0000 |
| Subject: | note 18409 deleted from function.uniqid by irc-html | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-25666@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