note 26999 added to function.is-dir

From: Date: Wed, 20 Nov 2002 03:02:00 +0000
Subject: note 26999 added to function.is-dir
Groups: php.notes 
Request: Send a blank email to php-notes+get-39727@lists.php.net to get a copy of this message
Too fast on submitting errors guys. Look at this code: if ($dir = @opendir("../wam/www")) { while (($file = readdir($dir)) !== false) { (*)if (is_dir($file)) { echo $file."<br />"; } } closedir($dir); } On (*), it says is_dir($file). This will most of the time return false except if $file == getcwd()."/".$file (means that $file is in the current working directory), which is usually not the case or what we want... but if you do the following : $path = "any path"; // even "." if ($dir = @opendir($path)) { while (($file = readdir($dir)) !== false) { if (is_dir($path."/".$file)) { echo $file."<br />"; } } closedir($dir); } then this would do the job without doing any chdir... even on Linux and Windows! JP. -- http://www.php.net/manual/en/function.is-dir.php http://master.php.net/manage/user-notes.php?action=edit+26999 http://master.php.net/manage/user-notes.php?action=delete+26999 http://master.php.net/manage/user-notes.php?action=reject+26999

« previous php.notes (#39727) next »