How can I extract specific sub string from a Main String from specific string to specific end String. Like I have below path
your path is D:///path/to/required/directory/sample/subdirectory/a/b/abc/sample.text
from above path I want to extract sub string from /sample to abc. In detail
/sample/subdirectory/a/b/abc
I tried with other substring functions but no success.
Can anybody help me for this?
I had tried with one of example given in php.net site
function reverse_strrchr($haystack, $needle, $trail)
{
return strrpos($haystack, $needle) ? substr($haystack, 0, strrpos($haystack, $needle) + $trail) : false;
}
but it gives me below path but I want to start from /sample to end
your path is D:///path/to/required/directory/sample/subdirectory/a/b/abc
/samplewill always be available in path.