I would like to modify html string from wysiwyg. After saving data to database my text looks like:
something bla bla
<p> something bla bla bla ba</p>
<h3 class"blabla"> bla bla bla</h3>
<p class"smtg"> another text bla bla <a href="blabla" class="blabla2">Nice url</a> </p>
<ul>
<li>lilislist</li>
<li>lilislist</li>
<li>lilislist</li>
<li>lilislist</li>
</ul>
<img src="blabla.jpg">
bleblebleblebe
<a href="blabla" class="blabla2" target="" id="notblabla">Nice url2</a>
Of course this is only example.
I would like to add additional paragraf(eg.<p class="special">special text</p>
) before each <a>
and <img>
element. However elements <a>
and <img>
must keep all attributes etc.
I know that this is easy to do with jquery but I can't use JavaScript here. It must be done by PHP.
Do you know how I can do it? Let's suppose that my string with html tags is assigned to $DBdata.