I thought I had cracked this nut from a previous discussion. http://forums.adobe.com/message/4741283#4741283 DirectoryIterator works great on my local testing server. But on the remote site, results are an unsorted mess. I found a script that takes care of that pretty nicely. <?php class SortingIterator implements IteratorAggregate { private $iterator = null; public function __construct(Traversable $iterator, $callback) { if (!is_callable($callback)) { throw new InvalidArgumentException('Given callback is not callable!'); } $array = iterator_to_array($iterator); usort($array, $callback); $this->iterator = new ArrayIterator($array); } public function getIterator() { return $this->iterator; } } ?> <!--results--> <ul> <?php function mysort($a, $b) { return $a->getPathname() > $b->getPathname(); } $it = new SortingIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator('PATH/MY_DIRECTORY')), 'mysort'); foreach ($it as $file) { echo '<li><a href="' . $file . '">' . $file->getFilename() . '</a> - ' . $file->getSize() .' bytes </li>'; } ?> </ul> All I need now is a simple way to convert getSize results from bytes to MB. Any ideas? Thanks, Nancy O.
... View more