php readdir and is_dir

directory, php

Solution

Try this and check. Just a try...

$handle = opendir("files/");
while(($entry = readdir($handle)) !== false)
{
    if($entry == "." || $entry == "..")
    {
        continue;
    }
    elseif(is_dir("files/".$entry))
    {
        echo "Directory:$entry<br />";
    }
}

Problem

I am testing out the functions of directory handling. I have a fold/directory that contains the following: 0 File folder false File folder my_pictures File folder MVI_3094 mov file img01 jpeg image etc... I wrote the following code to traverse the directory and print out specific resutls ``` $handle = opendir("files/"); while(($entry = readdir($handle)) !== false) { if($entry == "." || $entry == "..") { continue; } if(is_dir($entry)) { echo "Directory:$entry<br />"; } } ``` My only problem is that the second "if" statement does not output the results of ``` echo "Directory:$entry<br />"; ``` even though the entry is a directory. I have checked the entry manually with the "var_dump" function and it returns true as a directory. Any suggestions would help

Original source