Thursday, 31 July 2014

How to list files in Main directory & its Sub directory in dynamically in php?

$directory = substr(DIR_BASE,0,-1);
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
$i=1;
while($it->valid()) {
 if (!$it->isDot()) {
    echo "$i\n";
    echo 'SubPathName: ' . $it->getSubPathName() . "\n";
    echo 'SubPath:     ' . $it->getSubPath() . "\n";
    echo 'Key:         ' . $it->key() . "\n\n";
    $i++;
 }
 $it->next();
}

No comments:

Post a Comment