Iterate directory recursively
Snippet for iterating directories recursively
function iterateDir($sPath)
{
$aRes = array();
foreach(new DirectoryIterator($sPath) as $oItem)
{
if($oItem->isDir())
{
(!$oItem->isDot() ? $aRes[$oItem->getFilename()] = iterateDir($oItem->getPathname()):0);
continue;
}
$aRes[] = $oItem->getFilename();
} return $aRes;
}
print_r(iterateDir('./test_dir'));
Url: http://sklueh.de/2012/11/verzeichnis-rekursiv-mit-php-auslesen/
Language: PHP | User: sklueh | Created: Sep 24, 2013