Removing p tags from around img tags

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

By dsternalski - April 25, 2010

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

By dsternalski - April 26, 2010

Hi, this worked thanks.

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

By gkornbluth - April 26, 2010

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