The RecursiveDirectoryIterator provides an interface for iterating recursively over filesystem directories.
<?php $path = realpath('E:\xampp\htdocs\test'); $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); foreach($objects as $name => $object){ echo "$name\n".PHP_EOL; } ?>