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;
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!=..))
Chris wrote:
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!=.) ||
On Tuesday 28 September 2004 03:54, Mark wrote:
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.
Because is_dir() expects a path to the file as well, otherwise it would be
trying to
--- John Nichel [EMAIL PROTECTED] wrote:
Chris wrote:
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.
--- Jason Wong [EMAIL PROTECTED] wrote:
On Tuesday 28 September 2004 03:54, Mark wrote:
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.
Because is_dir() expects a path to the
Mark wrote:
--- John Nichel [EMAIL PROTECTED] wrote:
Chris wrote:
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
--- Jason Wong [EMAIL PROTECTED] wrote:
On Tuesday 28 September 2004 03:54, Mark wrote:
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.
Because is_dir() expects a path to the
* Thus wrote Mark:
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;
John Nichel wrote:
Chris wrote:
if (is_dir($file) || ($file!=.) || ($file!=..)) continue;
That will match everything and anything, files and dot directories...
The first statement by the OP should work fine. All three will eval
to true if it is a directory, and the directory isn't . or ..
10 matches
Mail list logo