Jump to content

remove innitial <p> and </p> tags


shahzad

Recommended Posts

i am using tiny_mce as a text editor for my CMS.

buy now the problem is it add <p> tag with data

 

so while retrieving the data for front end i get an extra space. so there is any why that i can remove <p> </p> from first paragraph.

 

i tried using strip_tags()... but it strip all the others tag like <br> etc etc..

 

 

Link to comment
https://forums.phpfreaks.com/topic/185449-remove-innitial-and-tags/
Share on other sites

i tried this way but it didnt work

$input = $query_data['PageContent'];

$ouput = preg_replace(array('#<p>#', '#</p>#'), '', $input, 1);

echo $output;

 

 

so i tried like this its working fine. but is it the good to do?

 

$outout = str_replace("</p>","<br />",str_replace("<p>", "", "$query_data[PageContent]"));

echo $output;

That doesn't do what you asked for. You said you wanted to keep everything but the first set of <p></p> tags, your code removes them all. As far as I can tell the code I gave you, given the example input you gave does exactly what you asked for.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.