Removing p tags from around img tags

4 posts by 2 authors in: Forums > CMS Builder
Last Post: April 26, 2010   (RSS)

Hi,

I'm trying to remove p tags from img tags. The code I have is:

<div class="topFeature">
<?php
$content = $featureRecord['content'];
$regExp = "/<p>.*?(<img.*?)<\/p>/";
preg_match($regExp, $content, $aImg);
echo $aImg[1];
echo $content;?>
</div>

This works to a point, but it duplicates the image.

Any suggestions would be highly greatful!

Thanks.

Re: [gkornbluth] Removing p tags from around img tags

Hi, this worked thanks.

Re: [dsternalski] Removing p tags from around img tags

Glad to hear it.

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php