There is some good code there, but it has a fatal flaw. It doesn't merge keys together. Perhaps that's my fault, I didn't point that part out. The reason the values are arrays (er, references to arrays... ) is so that the various values associated with a key can be collected (in order of collection even... hehe)