Directory Sorts on Mac and Linux?
Posted: Tue Jul 20, 2010 8:37 pm
I've written a function that lists directories. On my development environment (Mac OS X), it lists the directories in ascending order but under Linux the same code lists them in the order in which they were created.
...
I get the same sort orders even if I use different a function to iterate through my directory tree.
Is there some other factor affecting sort order that I'm not aware of?
Thanks.
Code: Select all
$startPath = 'documents/';
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($startPath),
RecursiveIteratorIterator::SELF_FIRST);
foreach($iterator as $file)
{
if($file->isDir())
{ $fn = $file->getFilename();
echo $fn;
}
}
I get the same sort orders even if I use different a function to iterate through my directory tree.
Code: Select all
foreach (new DirectoryIterator('documents') as $file)
{
print $file->getPathname() . "<br />";
}
Thanks.