paatrick

Alle Dateien rekursiv auflisten mit Filter für einen Dateityp

Jan 27th, 2021
716
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   $startdir = "./";
  2.   $extension = '/\.jpg$/';
  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