paatrick

Alle Dateien rekursiv auflisten mit Filter für mehrere Dateitypen

Jan 27th, 2021
764
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   $startdir = "./";
  2.   $extension = '/\.(?:jpg|gif|html)$/i';
  3.  
  4.   $iterator = new RecursiveIteratorIterator(
  5.     new RecursiveDirectoryIterator($startdir)
  6.   );
  7.   $selected_files = new RegexIterator($iterator, $extension);
  8.   foreach($selected_files as $file) {
  9.     if(!$file->isFile()) {
  10.       continue;
  11.     }
  12.     echo $file->getPathname() . "\n";
  13.   }
RAW Paste Data