Reading Directory Contents in PHP


Open and read the contents of a directory, excluding the special entries “.” and “..”.

Source Code

if ($handle = opendir('path/to/directory')) {
    while (false !== ($entry = readdir($handle))) {
        if ($entry != "." && $entry != "..") {
            echo "$entryn";
        }
    }
    closedir($handle);
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments