I need to convert the string This <span style="font-size: 16px;" style="color: red;">is</span> a test.
to This <span style="font-size: 16px; color: red;">is</span> a test.
There's also the possibility that there could be more than two matches or that there could be a style
, then a class
, then another style
, and the style
s would need to be combined. And they won't always be span
s
Unfortunately Tidy isn't an option as it is more over-bearing in it's cleaning than this project can accommodate.
Going the DOM document route won't work since multiple style attributes isn't valid, so it only gets the contents of the first one.
I'd like to do it with preg_replace, but getting just the matches from one tag is proving to be quite difficult.
If it makes things easier, they start life as nested tags. I have a preg_replace that combines them from there and gives this output.