Remove <p> </p> tags
I have this text block
<p class="text"><?php echo ($record['content']) ?></p>
but i need to remove all the <p> </p> tags from the statement inside the content, it is using WYSIWYG and i cant change it to text block because it needs to be able to bold font and underline and so on.
KC Media Solutions
Here's a short recipe from my CMSB Cookbook http://www.thecmsbcookbook.com that might help:
REMOVING THE <P>TAGS INSERTED BY THE TINYMCE EDITOR
CMSB uses the TinyMCE WYSIWYG editor and therefore is pretty much stuck with the concepts that it uses.
If using a textbox or a text field won’t work for you and you’re using the WYSIWYG, here’s an idea that Dave at
Interactive tools came up with in response to the issue of <p> tags.
<!-- remove leading <p>, do this _before_ displaying field value -->
<?PHP $record['yourfieldname'] = preg_replace("/^\s*<p>/i", "", $record['yourfieldname'] ); ?>
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
I just want to confirm what you're trying to achieve. Do you want to remove all of the opening / closing p tags from a bock of text, and replace them with line breaks? Or do you want to add the class text to each p tag in the block?
I'm wondering if there is a simpler way to do this using CSS instead of doing a find and replace with PHP. Perhaps wrapping the content with a div instead of a p tag, then styling the p tags inside the div instead would work?
PHP Programmer - interactivetools.com