By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,669 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

Generating GUID tags with php

P: n/a
Does anyone have any suggestions on generating GUID (Globally Unique
Identifier) tags with php?
They would need to be in the format
4402bd8a-cd51-40ea-99d7-b510e89e344b

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.
Feb 26 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Gary Hasler wrote:
Does anyone have any suggestions on generating GUID (Globally Unique
Identifier) tags with php?
They would need to be in the format
4402bd8a-cd51-40ea-99d7-b510e89e344b

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.
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:

http://pecl.php.net/package/uuid

Jeremy
Feb 26 '08 #2

P: n/a
Jeremy wrote:
>
Gary Hasler wrote:
Does anyone have any suggestions on generating GUID (Globally Unique
Identifier) tags with php?
They would need to be in the format
4402bd8a-cd51-40ea-99d7-b510e89e344b

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.

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:

http://pecl.php.net/package/uuid

Jeremy
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
file!

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!)
Feb 26 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.