A regular expression is required for preg_replace.
“Another question” did not answer this question, because not all the tags that I want to remove are not empty.
I need not only to remove empty tags from the HTML structure, but also tags containing line breaks, as well as spaces and / or their html code.
Possible codes:
</ amp; NBSP; & Amp; thinsp; & Amp; EnSP; & Amp; EPRS; & Amp; # 8201; & Amp; # 8194; & Amp; # 8195;
BEFORE deleting matching tags:
<div> <h1>This is a html structure.</h1> <p>This is not empty.</p> <p></p> <p><br /></p> <p> <br /> &;thinsp;</p> <p> </p> <p> </p> </div>
AFTER removing matching tags:
<div> <h1>This is a html structure.</h1> <p>This is not empty.</p> </div>
source share