Odd result from readdir()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


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.


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux