Odd result from readdir()

John <[email protected]>
Newsgroups gmane.comp.php.general
Message-ID <[email protected]>
I am trying to read the filenames in a directory using readdir().  There are two files and I cloned
the example in the opendir() documentation so the problem is probably not being caused by my coding:

My script running from the command line:

$indir = "/usr/shipresp/";
$outdir = "/usr/shipresp/";

if (is_dir($indir))
  {
   if ($dh = opendir($indir))
     {
      while ($filename = (readdir($dh) !== false))
        {
         echo "\nfound filename " . $filename;

        }
     }
  }
?>

The result is not a list of file names:

found filename 1
found filename 1
found filename 1
found filename 1

Note the directory only has two files so I am assuming files 3 and 4 are this directory and its
parent ---> ie ./ and ../  (?).

I have the same problem with fgets($file); docs say it returns a string and all I get is "1".  I
resolved that problem by using fgetcsv($file,,"\t") since the lines are actually a csv file anyway,
but my question is why I don't get the expected results.  

Been playing with this off and on for several days now and the directory list is critical to what I
am doing.

Thanks in advance.

John
======
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.