Skip to content

Instantly share code, notes, and snippets.

@quilime
Created November 11, 2014 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quilime/3fc0cbd4a663d09c07ed to your computer and use it in GitHub Desktop.
Save quilime/3fc0cbd4a663d09c07ed to your computer and use it in GitHub Desktop.
<?php
class MyRecursiveFilterIterator extends RecursiveFilterIterator {
public function accept() {
return
$this->current()->isDir() &&
strpos($this->current()->getFilename(), '.') === false;
}
}
$dirItr = new RecursiveDirectoryIterator('/Users/gdunne/Downloads/', RecursiveDirectoryIterator::SKIP_DOTS);
$filterItr = new MyRecursiveFilterIterator($dirItr);
$itr = new RecursiveIteratorIterator($filterItr, RecursiveIteratorIterator::SELF_FIRST);
foreach ($itr as $filePath => $fileInfo) {
echo $fileInfo . PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment