I have the following to replace uppercase HTML tags with lowercase ones.
$output = preg_replace("%<(/?[A-Z].*?)>%s",strtolower('$1'),$output);
The matching seems to be working well (in my RegEx testing site), but the replacement isn’t.
<EM>TEST</EM> becomes EMTEST/EM
Hoping someone can point me in the right direction on this.
You are calling
strtoloweron"$1"and then using the result (which is just$1again) to replace to.Instead, use
preg_replace_callbackand have the callback be:function($m) {return strtolower($m[0]);}