Jump to content

Help with replacing only the first p tags with a header tag


mits

Recommended Posts

hi, i have an article with several paragraphs. However i would like the first paragraph to be converted into a header.

 

string replacement will not work as it will replace all the p tags. i just want the 1st set of p tags to be replaced.

 

can anyone help?

 

thanks

Do a search for the first </p> tag (I'm pretty sure you can limit it to first found, somehow) and chop off everything before that into a variable. Do the str_replace on the variable. Reattach to the rest.

 

Or use preg_replace(). Brush up on regex-fu.

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.