Moshe
Moshe

Reputation: 58107

PHP DirectoryIterator help

In the following code, what can be called instead of ->getFilename()?

<?php

foreach (new DirectoryIterator('../moodle') as $fileInfo) {
    if($fileInfo->isDot()) continue;
    echo $fileInfo->getFilename() . "<br>\n";
}

?>

PS, I have seen the documentation. Please don't link to here.

Thanks for the help.

EDIT:

After posting this I realized that the Docs had the answer. My real question becomes, what do the other methods do? The Docs seem to be limited in regards to that.

Upvotes: 1

Views: 402

Answers (1)

prodigitalson
prodigitalson

Reputation: 60413

EDIT: Oops misread your code. What exactly are you after instead of the filename? youve seen the docs so you know there are methods for both the full path (getPathname) and just the path to the containing dir (getPath)... Im not sure what you want here...

I assume you want the directory name of . or .. so to get that you could use getPath and then pop the last/second-to-last segment off or you could just use dirname($fileInfo->getPathname())

Upvotes: 2

Related Questions