Newbie: recursing directories

From: Date: Mon, 03 Jul 2000 21:00:45 +0000
Subject: Newbie: recursing directories
Groups: php.general 
Request: Send a blank email to php-general+get-4576@lists.php.net to get a copy of this message
I have little bit of code that simply lists the contents of directories; However the code will only list the contents of the first directory recursed. Do I have some kind of directory pointer problem? Also, I cannot get the "if ($file != "." && $file != "..") code to work at all!!? which is why I use readdir twice to bypass the . and .. entries. Any help appreciated Mark ##################################################### Mark Newnham Application Design Associates, Inc 6021 S.Syracuse Way #302 Englewood, CO 80111, USA ##################################################### <?php $dh=opendir("../doc"); echo "Files:\n"; $file = readdir($dh); $file = readdir($dh); while ($file = readdir($dh)) { if (is_dir("../doc/$file")) { echo "Directory $file<br>"; readSubDir($file); } } echo "FILE=$file"; closedir($dh); ?> <?php function readSubDir($dirname){ echo "Reading files for directory $dirname<br>"; $sdh=opendir("../doc/$dirname"); $sfile=readdir($sdh); $sfile=readdir($sdh); while ($sfile = readdir()) { echo "SUBDIRFILE=$sfile<br>"; } echo "Closing...<br>"; closedir($sdh); } ?>

« previous php.general (#4576) next »