glennn.php Posted July 28, 2010 Share Posted July 28, 2010 i know how to get my current directory, and the root path, but what i'm needing to do is find the levels of the current dir, for instance, if i'm in: domain.com/folder1 or if i'm in domain.com/folder1/folder2 or if i'm in domain.com/folder1/folder2/folder3 can someone help? thanks much GN Link to comment https://forums.phpfreaks.com/topic/209168-finding-current-directory-levels/ Share on other sites More sharing options...
Pikachu2000 Posted July 28, 2010 Share Posted July 28, 2010 Have a look at getcwd(), it's probably what you need. Link to comment https://forums.phpfreaks.com/topic/209168-finding-current-directory-levels/#findComment-1092392 Share on other sites More sharing options...
glennn.php Posted July 28, 2010 Author Share Posted July 28, 2010 that's what i'm using, but that returns the entire server path: /home/content/n/j/l/njlieman/html/dir1/dir2/dir3 where i'm trying to get whether i'm dir1 or whether 2 or 3 - what i need is how deep i am below the root (html, or domain.com) Link to comment https://forums.phpfreaks.com/topic/209168-finding-current-directory-levels/#findComment-1092394 Share on other sites More sharing options...
glennn.php Posted July 29, 2010 Author Share Posted July 29, 2010 that's what i'm using, but that returns the entire server path: /home/content/n/j/l/njlieman/html/dir1/dir2/dir3 where i'm trying to get whether i'm dir1 or whether 2 or 3 - what i need is how deep i am below the root (html, or domain.com) figured it out. i just tested for an existing file in another folder... if (file_exists(file.php)) { i'm in root/ } elseif (file_exists(../file.php)) { i'm in root/folder1/... } easy. solved. Link to comment https://forums.phpfreaks.com/topic/209168-finding-current-directory-levels/#findComment-1092400 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.