Answers for "how to get all files in directory and subdirectories php"

PHP
11

list all files in directory php

$path    = './';
$files = scandir($path);
$files = array_diff(scandir($path), array('.', '..'));
foreach($files as $file){
  echo "<a href='$file'>$file</a>";
}
Posted by: Guest on November-05-2020
0

require all files in directory php

foreach (scandir(dirname(__FILE__)) as $filename) {
    $path = dirname(__FILE__) . '/' . $filename;
    if (is_file($path)) {
        require $path;
    }
}
Posted by: Guest on September-02-2021

Code answers related to "how to get all files in directory and subdirectories php"

Browse Popular Code Answers by Language