I am creating some RSS feeds using PHP (5.2) from a MySQL db specifically for an iPhone app I am making through AppMakr.
They are taken from articles on a website which contain images embedded in them, however in the feeds they don't look great. What I want to try and do is whenever there is an image surround it in <p>
so they are on their own line and don't try to wrap around article text.
The format of a image is like this:
<a rel="lightbox" href="http://images.domain.comk/543/image1.jpg"><img class="imageright" src="http://images.domain.comk/543/image1.jpg" alt="" width="300" height="250" /></a>
So basically surrounded with a <a href>
and with a class of "imageright" or "imageleft".
What I would love to change this to is:
<p><img src="http://images.domain.comk/543/image1.jpg" alt="" width="300" height="250" /></p>
Basically removing the href and imagexxxx class and surrounding in p tags.
I am thinking preg_replace will prob have to be used, but at a loss to what I would actually use for it. Any help is very appreciated.