I need to traverse recursively through a directory tree and get all sub-directory paths and has written a snippet to do that.
<?php
$path = "D:\webroot\phpvietnamcms";
foreach (new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_PATHNAME), RecursiveIteratorIterator::CHILD_FIRST) as $file => $info) {
if ($info->isDir())
{
echo $file."<br />";
}
}
?>