I have a string:
[startstring]hello = guys[endstring] hello guys [startstring]jerk = you[endstring] man this is good!!!
I would like remove everything in between [startstring] and [endstring], all the matches, and also remove the [startstring] and [endstring] from the string. So like the result would be:
hello guys man this is good!!!
and the deleted stuff would be:
[startstring]hello = guys[endstring] hello guys [startstring]jerk = you[endstring] man this is good!!!
See what I mean?
I would like to echo the resulted stuff, without the [startstring] and [endstring] stuff, as shown above. 🙂
Hope I’m mostly clear. 🙂
How would I go about accomplishing this in PHP? Would this envolve some sort of RegEx? Could you provide a sample code?
Thanks so much in advance! 🙂
Edit: Could this code be modified or be used somewhat to complete the task?
preg_match_all('/\[startstring\](.*?)\[endstring\]/s', $input, $matches);
To achieve that you just need to change your method name, you should use preg_replace instead
preg_match_all:Searches subject for matches to pattern and replaces them with replacement.
Code
Output