I can't figure out how to replace html special characters (such as "& amp;" or "& quot;") within a string, but ONLY when they occur between < and >. Is there a way, using preg_replace (or some other method) to do this?
I want to replace html special characters with their non-special equivalents (<, &, >) in each substring starting with < and ending with >, but not outside these delimiters.
Do I need to split out the sections starting with < and ending with >, and then do a preg_replace on them, or can I find these substrings within a larger block of text and do the replaces only within these sections?
Does this make any sense? I'll try to clarify it if not. Basically, I'm starting with text that's been encoded using htmlentities. I want to leave all the regular, human-readable text in html entity form, but I want to decode the angle brackets around html tags, and any special characters within those tags (like ampersands, doublequotes, etc.) so the tags and their contents will be correct html tag code, rather than html meant to be read as text.
If you have any ideas, they will be greatly appreciated!
Bob