erron Posted July 18, 2006 Share Posted July 18, 2006 hi,can someone help me, i know how to get a site url and how to get part of a string, but what im finding difficult is getting the end of a url, for example:http://www.mysite.com/mypage/index.phpfrom this, how would i get 'mypage' as a string? Link to comment https://forums.phpfreaks.com/topic/14986-getting-end-of-url-as-string/ Share on other sites More sharing options...
pixy Posted July 18, 2006 Share Posted July 18, 2006 You mean the directory that index.php is in? Link to comment https://forums.phpfreaks.com/topic/14986-getting-end-of-url-as-string/#findComment-60206 Share on other sites More sharing options...
yonta Posted July 18, 2006 Share Posted July 18, 2006 Don't know if there's a simpler solution (hope there is) but you could do this:$path = 'http://www.mysite.com/example/index.php';print substr(strrchr(dirname($path), '/'), 1); //will return exampleIf you want to just get the current directory (and not parse a url string), use <a href="http://pt.php.net/getcwd">getcwd</a> .best Link to comment https://forums.phpfreaks.com/topic/14986-getting-end-of-url-as-string/#findComment-60210 Share on other sites More sharing options...
erron Posted July 19, 2006 Author Share Posted July 19, 2006 Thanks guys, tried that and a few other work arounds and settled with using str_replace and php_self Link to comment https://forums.phpfreaks.com/topic/14986-getting-end-of-url-as-string/#findComment-60268 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.