Jump to content

PHP advice for search and replace


jwhite68

Recommended Posts

I want to find a way, whereby I can detect any occurence of a text string in a variable (lets say $desc), that occurs immediately after a </UL> and insert a start and end <P></P> around that text string (immediately after the </UL>.  Can anyone advise how I could achieve this using something like preg_replace?

 

eg. If the source text is:

 

This is a test. <br />
Heres a car. <br />
<UL><br />
<LI>Point 1<br />
<LI>Point 2<br />
<LI>Point 3</LI></UL>This is my text string.

 

So I want the output to be:

 

This is a test. <br />
Heres a car. <br />
<UL><br />
<LI>Point 1<br />
<LI>Point 2<br />
<LI>Point 3</LI></UL><P>This is my text string.</P>

 

But it needs to make this change wherever it finds this occurence of a text string after a </UL>.

 

Link to comment
https://forums.phpfreaks.com/topic/70863-php-advice-for-search-and-replace/
Share on other sites

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.