I have the a block of HTML code read into a variable $content
:
<div class="entry">
<table class="old-style1 old-style2">
<tr>
<td></td>
</tr>
</table>
</div>
I would like to remove all classes/attributes of the existing <table>
element and replace it with new classes and another <div>
wrapper.
to:
<div class="entry">
<div class="table-wrapper">
<table class="new-style1 new-style2">
<tr>
<td></td>
</tr>
</table>
</table>
</div>
I might have multiple table
elements within the <div class="entry">
block. And I would like to apply the same style modification to all of them.
How can I get the done in the PHP level using RegEx
or other methods?