if (is_dir($file) && ($file!=".") && ($file!="..")) {
$users[]=$file;
}
It's only adding it to the array if all 3 of those are true. and since $file can't be
both '.' and '..' at the same time, it's never matching.
I'd do something like:
if (is_dir($file) || ($file!=".") || ($file!="..")) continue;
Mark wrote:
I'm having a problem I haven't encountered before. I'm using PHP
4.3.4 (upgrading the 4.3.9, but humor me) on Windows.
I'm using the following code snippet to try to get all the
subdirectories of a directory into an array.
$maildir=MERCURY."/MAIL";
$handle=opendir($maildir);
// echo $handle;
while ($file = readdir($handle)) {
// echo $file;
// echo is_dir($file)."<BR/>";
if (is_dir($file) && ($file!=".") && ($file!="..")) {
$users[]=$file;
}
}
What this should do (if I'm not a complete idiot), is put all the
true subdirectories (excluding . and ..) into the array $users. There
are two additional subdirectories under the $maildir directory.
However the array is empty. As you can see, I tried echoing out $file
and whether it is a directory, but it came up as not recognizing the
directories as such.
With the echos above in place, I get the resource handle, and it
echos everything you would expect except that is_dir() fails to
recognize the directories.
It DOES recognize . and .. as directories, for some bizarre reason.
And no, I can't switch to linux.
Any ideas?
Mark
=====
Mark Weinstock
[EMAIL PROTECTED]
***************************************
You can't demand something as a "right" unless you are willing to fight to death to
defend everyone else's right to the same thing.
***************************************
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php