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
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;

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.