/ Published in: PHP
Takes advantage of the SPL. Much easier and maintainable than the previous revisions. Haven't done any benchmarks yet but I imagine it is much faster. "If you want to omit directories, remove the RecursiveIteratorIterator::SELF_FIRST part."
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); foreach($objects as $name => $object){ echo "$name\n"; } ?>
URL: http://us2.php.net/manual/en/class.recursivedirectoryiterator.php