note 26999 deleted from function.is-dir by tomsommer

From: Date: Sat, 07 Aug 2004 04:22:20 +0000
Subject: note 26999 deleted from function.is-dir by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-74131@lists.php.net to get a copy of this message
Note Submitter: jpleveille@webgraphe.com ---- 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.

« previous php.notes (#74131) next »