I have this PHP Code:
$rootpath = \'../admin/\';
$inner = new RecursiveDirectoryIterator($rootpath);
$fileinfos = new RecursiveIteratorIterator($inner);
for
You can use RecursiveFilterIterator to filter dirs and in fooreach loop you have only accepted dirs.
class MyDirFilter extends RecursiveFilterIterator {
public function accept() {
$excludePath = array('exclude_dir1', 'exclude_dir2');
foreach($excludePath as $exPath){
if(strpos($this->current()->getPath(), $exPath) !== false){
return false;
}
}
return true;
}
}
$rootpath = '../admin/';
$dirIterator = new RecursiveDirectoryIterator($rootpath);
$filter = new MyDirFilter($dirIterator);
$fileinfos = new RecursiveIteratorIterator($filter);
foreach($fileinfos as $pathname => $fileinfo)
{
// only accepted dirs in loop
}