keeps21 Posted January 15, 2009 Share Posted January 15, 2009 I'm currently running a str_replace() function on variable which contains a string. The str_replace() function currently replaces the path to images. basically searches for ../ and replaces with ./ What I need to do is run the str_replace() function until the following comment in the string is reached <!-- STOP replacing path --> Not sure how to do this though. Can anyone give me a pointer? Any help would be appreciated. Cheers. Link to comment https://forums.phpfreaks.com/topic/140934-solved-run-str_replace-until-a-certain-piece-of-text-is-found/ Share on other sites More sharing options...
Mark Baker Posted January 15, 2009 Share Posted January 15, 2009 Split the string into two parts using the "<!-- STOP replacing path -->" as the separator $strParts = explode("<!-- STOP replacing path -->",$string); run your search replace against $strParts[0]. implode it all back together again $string = implode("<!-- STOP replacing path -->",$strParts); Link to comment https://forums.phpfreaks.com/topic/140934-solved-run-str_replace-until-a-certain-piece-of-text-is-found/#findComment-737645 Share on other sites More sharing options...
keeps21 Posted January 15, 2009 Author Share Posted January 15, 2009 Sorted now Thanks very much. Link to comment https://forums.phpfreaks.com/topic/140934-solved-run-str_replace-until-a-certain-piece-of-text-is-found/#findComment-737663 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.