That bit of code makes perfect sense to me.
I'm not too hot on PHP, i'm not sure where to insert the code. You said the top level of the array and in each array's instances array.
But i'm not sure what this means, i've got a vague idea, could you possibly tell me what to look out for? Or maybe dumb it down so i know where to place the code, it would be greatly appreciated!
Thanks for the help so far it's been great!