natasha_thomas Posted March 10, 2011 Share Posted March 10, 2011 Folks, I want to extract certain portion form URL. Exmaple: http://abc.com/this-is-test.html Output should be this-is-test Another Example http://abc.com/this-is-yet-another-test.html Output should be this-is-yet-another-test I am not sure how it can be done with preg_match() and regex or something like that... Can someone help me with this please? Cheers Natasha Link to comment https://forums.phpfreaks.com/topic/230247-extracting-from-url/ Share on other sites More sharing options...
AbraCadaver Posted March 10, 2011 Share Posted March 10, 2011 You can use parse_url() and trim the extension or I would use: echo pathinfo('http://abc.com/this-is-yet-another-test.html', PATHINFO_FILENAME); Link to comment https://forums.phpfreaks.com/topic/230247-extracting-from-url/#findComment-1185734 Share on other sites More sharing options...
natasha_thomas Posted March 10, 2011 Author Share Posted March 10, 2011 You can use parse_url() and trim the extension or I would use: echo pathinfo('http://abc.com/this-is-yet-another-test.html', PATHINFO_FILENAME); Very Sweet.... Link to comment https://forums.phpfreaks.com/topic/230247-extracting-from-url/#findComment-1185741 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.