note 18409 added to function.uniqid

From: Date: Mon, 21 Jan 2002 23:45:42 +0000
Subject: note 18409 added to function.uniqid
Groups: php.notes 
Request: Send a blank email to php-notes+get-25665@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 -- http://www.php.net/manual/en/function.uniqid.php http://master.php.net/manage/user-notes.php?action=edit+18409 http://master.php.net/manage/user-notes.php?action=delete+18409 http://master.php.net/manage/user-notes.php?action=reject+18409

« previous php.notes (#25665) next »