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? Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.