Jump to content

finding current directory levels


glennn.php

Recommended Posts

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

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)

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.