Link to home
Start Free TrialLog in
Avatar of Chris Andrews
Chris AndrewsFlag for United States of America

asked on

replace last occurrence of a string with another string

arrgh...

Ok, I'm trying to find a way to get the last ending p tag </p> and place a string in front of it.

So:

$string = "<p>Some text</p><p>More text.<p/><p>Even more text.</p>";

$insert = " Here is an insert.";

results need to be:
---------
<p>Some text</p><p>More text.<p/><p>Even more text. Here is an insert.</p>
-----------

Help would be greatly appreciated - this has been quite a headache!

ASKER CERTIFIED SOLUTION
Avatar of Sandeep Kothari
Sandeep Kothari
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Chris Andrews

ASKER

Thank you! Yes, working perfectly -  Chris