Generating GUID tags with php

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Does anyone have any suggestions on generating GUID (Globally Unique
Identifier) tags with php?
They would need to be in the format

Specifically this is for adding accessibility for the PicLens browser
add-on (which uses an .rss file) to some of our photo gallery pages.  It
seems to require each thumbnail have an identical GUID tag in both the
html and the rss file.

Re: Generating GUID tags with php

Gary Hasler wrote:
Quoted text here. Click to load it

If a UUID is acceptable for you (GUID usually means Microsoft's
implementation of UUID; pretty much the same thing, just a 128-bit
unique identifier) then check out this PECL module:


Re: Generating GUID tags with php

Jeremy wrote:
Quoted text here. Click to load it

Thanks jeremy;
of course as always happens, shortly after posting I stumbled upon the
'perfect' solution: md5().
I can simply use the URL of each picture as string input to the md5
function, which produces a md5 hash (32 character hex). So it is
completely predictable, which I want; yet will NEVER be the same unless
the path to the picture is identical--in which case it will be the same

So I made this function (there may be a more elegant way to do it):
function MakeGUID ($str) {
    $h = "-";  //-- HYPHEN
    $gMd5 = md5($str);
    $guidTag = substr($gMd5,0,8) . $h . substr($gMd5,7,4) . $h .
substr($gMd5,11,4) . $h . substr($gMd5,15,4) . $h . substr($gMd5,19,12);
    return $guidTag;

...and use it in both the PHP file for the gallery page and the RSS
file, giving it the path to each image.
(Jeez PHP is brilliant...the only hard part is getting the right term to
search for.  I've never heard of md5!)

Site Timeline