» Birthday Bundle - Over $400 worth of Envato files for just $20

How to generate a Unique ID

Posted on August 30, 2008, Filled under PHP,  Bookmark it

A function that generates an unique id. It’s useful when you need to generate keys that have to be unique.

<?php
function GenerateUniqueID()
{
return md5(uniqid(rand(),1));
}

echo GenerateUniqueID(); // returns a 32 characters unique string
?>

Do you wish to receive the latest updates as soon as they are posted? Get our RSS Feed or Subscribe to the Newsletter!

Get our RSS Feed!

Related Posts

One Reply to "How to generate a Unique ID"

  1. Thanks for a short but helpful bit of information.

Leave a Reply


* = required fields

  (will not be published)


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Note: If you want to post CODE Snippets, please make them postable first!
(e.g. <br /> should be converted to &lt;br /&gt;)