Skip to content

Instantly share code, notes, and snippets.

@pavelmaca
Created August 1, 2010 10:46
Show Gist options
  • Save pavelmaca/503209 to your computer and use it in GitHub Desktop.
Save pavelmaca/503209 to your computer and use it in GitHub Desktop.
.php
<?php
public static function scanDir($patch, $pattern = false, $ignore = false){
$dir = new RecursiveDirectoryIterator($patch);
if( !$dir->isDir() ) throw new FileModelException("$patch must by directory");
$files= array();
foreach ($dir as $filename => $cur) {
if($ignore && in_array($file, $ignore)) continue;
if($pattern && !preg_match($pattern, $file)) continue;
$files[] = $file;
}
return $files;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment