ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button
  Working with Files in PHP, Part 3
Subject:   problem with read dir example
Date:   2003-06-02 23:25:40
From:   anonymous2
Working with Files in PHP, Part Three -

$mydir = new dir('/path/to/mydir');
while(($file = $mydir->read()) !== false) {
if(is_dir($mydir->path.$file)) {
echo "Directory: $file
} else {
echo "Filename: $file

This doesn't work. You are concatenating the path with the filename, but skipped tacking on the trailing slash. perhaps some OS's leave the trailing slash and some do not (I really don't know), in which case, a test for a trailing slash as the last char with egrep might be in order.