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 ? 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']); 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. 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! Link to comment https://forums.phpfreaks.com/topic/187539-getting-current-folder/#findComment-990338 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.