user5075489
user5075489

Reputation:

Can't get scandir to scan root directory

I've tried every path I can think of.

'' '/' 'htdocs/'

No matter what I try, I cant figure out how to scan the root directory.

So, how do you do it?

Current Code:

function pathing(){
    $files = scandir('/');

    foreach ($files as $file) {
        if ($file === '.' OR $file === '..') {

        } else {
            print_r($file . ' ');
        }
    }

}

Upvotes: 0

Views: 3214

Answers (1)

devlin carnate
devlin carnate

Reputation: 8591

I'm moving my comment to an answer in order to bring attention to the solution for others who stumble across this question.

The directory root location is accessible in the $_SERVER array.

$_SERVER['DOCUMENT_ROOT'] 

Upvotes: 3

Related Questions