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