Generating a List of Files in a Directory in PHP


Use scandir() to list all files and directories within a specified path.

Source Code

$files = scandir('path/to/directory');
foreach ($files as $file) {
    if (!in_array($file, array('.', '..'))) {
        echo $file . "n";
    }
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments