Code:
<div>
<font face="Arial, Verdana">
<span style="font-size: 13.3333px;">
<u>
Hello World
</u>
</span>
</font>
</div>
<div>
<font face="Arial, Verdana">
<span style="font-size: 13.3333px;">
<u>
Hello World2
</u>
<br>
</span>
</font>
</div>
<div>
<br>
</div>
<div>
<font face="Arial, Verdana">
<span style="font-size: 13.3333px;">
<u>
<br>
</u>
</span>
</font>
</div>
Output:- I wish to get exactly the same output as given below
<div>
<font face="Arial, Verdana">
<span style="font-size: 13.3333px;">
<u>
Hello World
</u>
</span>
</font>
</div>
<div>
<font face="Arial, Verdana">
<span style="font-size: 13.3333px;">
<u>
Hello World2
</u>
<br>
</span>
</font>
</div>
<br>
<br>
Here is what I have tried:
$html = preg_replace("/<div.*?>.*?<br.*?>.*?<\/div>/", "", $html);
but it is not working fine.
Please take a look on the code and suggest me how I can replace "div" tag from its starting to corresponding closing tag with "br" tag only when there is no text is present under "div" tag. As shown above in second "div" tag.