#45505 [Bgs]: DirectoryIterator default sorting error
| From: | jcknight at gmail dot com | Date: | Mon, 14 Jul 2008 14:22:41 +0000 |
| Subject: | #45505 [Bgs]: DirectoryIterator default sorting error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-126668@lists.php.net to get a copy of this message | ||
ID: 45505
User updated by: jcknight at gmail dot com
Reported By: jcknight at gmail dot com
Status: Bogus
Bug Type: SPL related
Operating System: Linux
PHP Version: 5.2.6
New Comment:
That is the problem, as it does not return the files in the order that
the operating system provides. In the file system, the order is:
enter_L.gif
enter_R.gif
mad_L.gif
mad_R.gif
but the DirectoryIterator provides the files as
enter_L.gif
mad_L.gif
enter_R.gif
mad_R.gif
Previous Comments:
------------------------------------------------------------------------
[2008-07-14 09:52:24] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
There is no sorting guaranteed and the files are returned in the order
the operating system provides.
------------------------------------------------------------------------
[2008-07-13 23:25:25] jcknight at gmail dot com
Description:
------------
The DirectoryIterator class does not iterate the directory how it is
organized on the file system.
Reproduce code:
---------------
<?php
$dir = new DirectoryIterator(".");
foreach($dir as $file) {
echo $file->current() ."\n";
}
?>
Expected result:
----------------
.
..
enter_L.gif
enter_R.gif
mad_L.gif
mad_R.gif
Actual result:
--------------
.
..
enter_L.gif
mad_L.gif
enter_R.gif
mad_R.gif
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45505&edit=1