This looks like it will work fine, I find the function a bit confusing unless you know exactly what is going on.  Can you add some more comments to this function and a description of the parameter at a minimum.  

if you pass it a "tag" it adds it to a static array and returns a md5, if you pass it a md5 it returns the original tag it if it exists.  If the md5 does not exist it returns nothing.