mits Posted October 5, 2010 Share Posted October 5, 2010 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 Link to comment https://forums.phpfreaks.com/topic/215193-help-with-replacing-only-the-first-p-tags-with-a-header-tag/ Share on other sites More sharing options...
iridys Posted October 5, 2010 Share Posted October 5, 2010 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. Link to comment https://forums.phpfreaks.com/topic/215193-help-with-replacing-only-the-first-p-tags-with-a-header-tag/#findComment-1119224 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.