note 16914 added to function.opendir

From: Date: Mon, 19 Nov 2001 01:24:02 +0000
Subject: note 16914 added to function.opendir
Groups: php.notes 
Request: Send a blank email to php-notes+get-20987@lists.php.net to get a copy of this message
hmm, works nice and good as long i got only 1 directory to look into. but tried to use it with multiple sub-dirs within a loop, just didn't work, all i get back is: 2 (or 3, 4 etc..) is not a valid Directory resource in "myphp" on line "nn" :-( the whole source looks like: <? $cwd = getcwd(); chdir($DOCUMENT_ROOT); $handle1=opendir('.'); while ($file = readdir($handle1)) { if (filetype($file) == "dir") { if ($file != "." && $file != "..") { $dirs[] = $file; }}} closedir($handle1); chdir($cwd); //now preparing the output, where i //also wonna list files of the sub-dirs: sort($dirs); while (list($b, $dir) = each($dirs)) { echo $dir; //nice } //now the 2nd part where i wonna get a //list of things out of the individual //sub-dirs $path = $DOCUMENT_ROOT.$dir; chdir($path); $handle2=opendir($path); while ($sl = readdir($handle2)) { //this was btw the line he complains //about :-( //and never arrives here: echo $sl; closedir($handle2); chdir($cwd); }} ?> really not what i expected, or do i deserve the error messages?? -- http://www.php.net/manual/en/function.opendir.php http://master.php.net/manage/user-notes.php?action=edit+16914 http://master.php.net/manage/user-notes.php?action=delete+16914 http://master.php.net/manage/user-notes.php?action=reject+16914

« previous php.notes (#20987) next »