#31435 [Opn->Bgs]: Readdir give unsorted file list output
| From: | tony2001@php.net | Date: | Fri, 07 Jan 2005 01:21:39 +0000 |
| Subject: | #31435 [Opn->Bgs]: Readdir give unsorted file list output | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-71544@lists.php.net to get a copy of this message | ||
ID: 31435
Updated by: tony2001@php.net
Reported By: info at rustelekom dot biz
-Status: Open
+Status: Bogus
Bug Type: *Directory/Filesystem functions
Operating System: Linux 2.6.9-1.6_FC2smp
PHP Version: 4.3.10
New Comment:
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
See http://php.net/readdir :
"The filenames are returned in the order in which they are stored by
the filesystem."
Previous Comments:
------------------------------------------------------------------------
[2005-01-06 23:44:33] info at rustelekom dot biz
Description:
------------
Hello,
On other system (with Fedora core 1 kernel version) same code give us
file and directory list result sorted by created time (so, file created
last - also showed as last in output list), but on this system we have
other result and it is looks as unsorted (or sorted not by file created
time in other words). On both system we use same locale (koi8r) and
filesystem type (ext3).
Sincerely Yours
Dima Ivanov
Reproduce code:
---------------
<?php
// Note that !== did not exist until 4.0.0-RC2
if ($handle = opendir('./')) {
echo "Directory handle: $handle<br>";
echo "Files:<br>";
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
echo "$file<br>";
}
/* This is the WRONG way to loop over the directory. */
/* while ($file = readdir($handle)) {
echo "$file\n";
} */
closedir($handle);
}
?>
Expected result:
----------------
Fedora 1 system
Directory handle: Resource id #2
Files:
.
..
SmallNuke_v1.zip
SmallNuke_v1
blocks
images
bandmin-1.6.tar.gz
includes
language
modules
themes
admin
robots.txt
modules.php
.htaccess
header.php
footer.php
index.php
mainfile.php
order
cgi-bin
test.php
myLogs
sql
spaw
banners
forum.sql
header.php.bak
eurodns.html
banners.php
.htaccess.bak
footer.php.bak
mainfile.php.bak
index.html.old
api
login
order.php
gate-order.inc.php
rupay.php
suspended.page
index.html
index.php.old
.htaccess.old
history < - this is file which newly created
Actual result:
--------------
Fedora 2 system
Directory handle: Resource id #2
Files:
auto.php
auto_ind.php
pictures
search.php
damp
.
sale.php
.htaccess
style
sale_ind.php
admin
test.php < - this is file which newly created
images
rasdel_ind.php
page.php
rasdel.php
include
..
index.php
logo.swf
description.php
reference.php
print.php
cgi-bin
order.php
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31435&edit=1