Thursday, April 12, 2012

How to grab string between two keywords in PHP

Not sure if this has been answered before - how can I grab string between two keywords?



For instance the string between a 'story' and a '?',



http://mywebsie.com/hello/blog/story/archieve/2012/5/?page=1    
http://mywebsie.com/blog/story/archieve/2012/4/?page=1
http://mywebsie.com/blog/story/archieve/2012/?page=4


I just want,



story/archieve/2012/5/
story/archieve/2012/4/
story/archieve/2012/


EDIT:



If I use parse_url,



$string = parse_url('http://mywebsie.com/blog/story/archieve/2012/4/?page=1');
echo $string_uri['path'];


I get,



/blog/story/archieve/2012/4/


but I don't want to include 'blog/'





No comments:

Post a Comment