focus72050 Posted June 21, 2007 Share Posted June 21, 2007 Hi Everyone. i do dirname(__FILE__) and i get for example /usr/local/a/b/c/d/e I need to get from this /usr/local/a/b/c How do i go about that? Quote Link to comment https://forums.phpfreaks.com/topic/56512-get-parent-directory/ Share on other sites More sharing options...
btherl Posted June 21, 2007 Share Posted June 21, 2007 There's actually a function specifically for that http://sg.php.net/manual/en/function.dirname.php Edit: In your case, it looks like you want to go 2 levels up. So just call the function twice if that's what you want. Things are messier if you want a trailing slash to be dealt with differently.. Quote Link to comment https://forums.phpfreaks.com/topic/56512-get-parent-directory/#findComment-279105 Share on other sites More sharing options...
genericnumber1 Posted June 21, 2007 Share Posted June 21, 2007 dirname(dirname(dirname(__FILE__))) messy eh? Quote Link to comment https://forums.phpfreaks.com/topic/56512-get-parent-directory/#findComment-279125 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.