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
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)

Link to comment
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)

 

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.