Hi,

I am using a script to list all the files in a directory.
I want to put a "/" after the filename if it is a directory.
It can only recognize "." and ".." as directory, but fail
to report other directories. What's wrong with is_dir?
Thanks.

My script:

<?php

$dir=".";
$dh = opendir($dir);

while($file = readdir($dh)){
if(is_dir($file)){
print "$file /<br>";
}else{
print "$file <br>";
}

}

closedir($dh);

?>

    I've experienced the same behavior. Using PHP 4.0 on Apache/Linux

      try this

      while($file = readdir($dh)){
      if(is_dir($file)){
      print $file . "/<br>";
      }else{
      print $file . "<br>";
      }
      }

        Actually this works better:
        <?php
        $dir = ".";
        $handle = opendir($dir);

        while ($file = readdir($handle)) {
        if ((($file != ".") && ($file != "..")) && (is_dir($file))) {
        print $file ."/<br>";
        }
        }

        ?>

          Still doesn't work in PHP3.

            Write a Reply...