note 16252 added to function.uniqid

From: Date: Mon, 22 Oct 2001 16:09:13 +0000
Subject: note 16252 added to function.uniqid
Groups: php.notes 
Request: Send a blank email to php-notes+get-19264@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+16252 http://master.php.net/manage/user-notes.php?action=delete+16252 http://master.php.net/manage/user-notes.php?action=reject+16252

« previous php.notes (#19264) next »