PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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.
PHP isn't actually going & getting the directory list - it's asking the operating system for the list. Apparently OS X & Linux give that list in a different order. I know glob() is subject to that difference, and it would appear DirectoryIterator() is as well.
I've never used DirectoryIterator(), so maybe there's an way to set which way it delivers the filenames - maybe a parameter to the constructor.
If not, what I would do is put the found filenames in an array, sort that array yourself, then output that sorted array.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Thankyou for clarifying the issue pickle.
When I run it using sort($iterator) it 'works' on OS X but Linux complains that sort expects an array.
Any idea how to sort and 'iterator' object?
Thanks!