I'd love to see your website if this is the best way you could approach this.
So I'm no high level PHP programmer but there are a few problems which stand out. Initially the first one that strikes is: you're re evaluating the condition in those if statements over and over even though there is no chance that more than one match will ever be found. Instead do something like:
I've tested this, it works fine, and not only is it way easier to read, it is also faster and easier to maintain in the future.
Now onto the use of "echo". When developing classes and functions that other developers are supposed to use, you should never ever do "echo" as a way of returning data. You should always use return! In this instance you are anticipating the need to print it out, when you never know what a developer will do with this, so it is always best to return data.
I'd make a proof of concept for it but after trying I determined the code to be incomprehensible and it'd necessarily require a rewrite. A friend suggested doing key-value pairs in an array.
Everything is updated now, will be cleaning up the deprecated content soon.
The code box on minecraftforum slightly distorts how the code looks, In which case I would recommend you
download the source code with the link I provided.