Remove all from removeStart to removeEnd

I like to remove all text and characters from the mark word removeStart to the mark word removeEnd
The code below doesn’t work correctly, but I hope it shows what I want.

[b]would-be code[/b]

$myText="This is my[COLOR="Red"]RemoveStart[/COLOR] This text should be 
removed.[COLOR="red"]RemoveEnd[/COLOR] text."

[b]the value of $removedText[/b]

This is my text.

A regular expression is what you’re after there, using something like [url=“”]preg_replace

you can find the positions of the mark word removeStart and the mark word removeEndover in the original string.
Then use substr_replace function.
Here is the details to use this function::::

$myText="This is myRemoveStart This text should be removed.RemoveEnd text.";

$output = preg_replace("#(myRemoveStart)(.*)RemoveEnd#", "", $myText);
echo $output ;

As pmw57 says, use a regex, here it is, I always need to practice them… :wink:

EDIT : sorry, forgot the multiline switch ‘s’ …

$output = preg_replace("#(myRemoveStart)(.*)RemoveEnd#s", "", $myText);