PHP - DirectoryIterator
<?php
$filePath = '/vagrant/data/anniballo.com';
/**
* Class FolderFilter
*/
class FolderFilter extends FilterIterator
{
/**
* @return bool
*/
public function accept()
{
return ($this->getInnerIterator()->isDir() && !$this->getInnerIterator()->isDot());
}
}
$filter = new FolderFilter(new DirectoryIterator($filePath));
foreach ($filter as $key => $value) {
echo $filter->getBasename().PHP_EOL;
}
// Output:
/*
log
wp-admin
wp-content
wp-includes
*/