Lamez Posted January 7, 2010 Share Posted January 7, 2010 How would I get the current folder of which my website is in? Pretty much, how would I edit $_SERVER['REQUEST_URI'] to show the last folder? Exmaple if REQUEST_URI = /folder1/another_folder/page.php how would I get /folder1 ? Quote Link to comment https://forums.phpfreaks.com/topic/187539-getting-current-folder/ Share on other sites More sharing options...
PravinS Posted January 7, 2010 Share Posted January 7, 2010 May this will help you. It will give you complete folder path. You can explode it with "/" character and take the last value of array for current folder name. $dir = dirname($_SERVER['REQUEST_URI']); Quote Link to comment https://forums.phpfreaks.com/topic/187539-getting-current-folder/#findComment-990168 Share on other sites More sharing options...
oni-kun Posted January 7, 2010 Share Posted January 7, 2010 How would I get the current folder of which my website is in? Pretty much, how would I edit $_SERVER['REQUEST_URI'] to show the last folder? Exmaple if REQUEST_URI = /folder1/another_folder/page.php how would I get /folder1 ? As suggested, you may do this: $location = '/folder1/another_folder/page.php'; $basedir = explode('/', $location); echo $basedir[1]; //Output: folder1 It will work on any length url, it simply gets the first folder. Quote Link to comment https://forums.phpfreaks.com/topic/187539-getting-current-folder/#findComment-990172 Share on other sites More sharing options...
Lamez Posted January 7, 2010 Author Share Posted January 7, 2010 Thanks for the help guys! Quote Link to comment https://forums.phpfreaks.com/topic/187539-getting-current-folder/#findComment-990338 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.