Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top