OK, that's what I need :
- Get all entries formatted like
%%something%%, as given by the regex/%%([A-Za-z0-9\-]+)%%/i - Replace all instances with values from a table, given the index
something.
E.g.
Replace %%something%% with $mytable['something'], etc.
If it was a regular replacement, I would definitely go for preg_replace, or even create an array of possible replacements... But what if I want to make it a bit more flexible...
Ideally, I'd want something like preg_replace($regex, $mytable["$1"], $str);, but obviously it doesn't look ok...
How should I go about this?
preg_replace_callback.gin your regex, e.g./%%([A-Za-z0-9\-]+)%%/gi[A-Za-z0-9-]class, you don't need to put the i modifier