How to extract string from within two strings or characters

Sometimes , you may need to extract string between two character or strings. for example you want to read name between two curly brackets in a string like {John Doe} or something similar to that.
Here, I will show you how to extract string from within two strings or character. I would appreciate if any one would share any function in built in PHP but I could not find so far (with my limited knowledge). So, here is a function I have created to perform the task. The function will input the source string need to be processed and two other strings one for start position and other for end position.

tip: strings for start position and end position should be different from each other.
Here is how you will use / call the function and get the result. In this example , I extracted the string from within two words of ‘quick’ and ‘lazy’.

download working example for ‘how to extract string from within two strings’

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.