note 60169 added to function.opendir

From: Date: Wed, 28 Dec 2005 16:26:59 +0000
Subject: note 60169 added to function.opendir
Groups: php.notes 
Request: Send a blank email to php-notes+get-100860@lists.php.net to get a copy of this message
In my previous post I ran into a problem with the "global" definition of $directorylist. If I called the function more than once on the same page it would combine the file lists. I looked at Lasse Dalegaard's example and used the following solution. remove global definition global $directorylist; REPLACE <? if ((($maxlevel) == "all") or ($maxlevel > $level)) { filelist($startdir . $file . "/", $searchSubdirs, $directoriesonly, $maxlevel, $level + 1); } ?> WITH <? if ((($maxlevel) == "all") or ($maxlevel > $level)) { $list2 = filelist($startdir . $file . "/", $searchSubdirs, $directoriesonly, $maxlevel, $level + 1); if(is_array($list2)) { $directorylist = array_merge($directorylist, $list2); } } ?> ---- Manual Page -- http://www.php.net/manual/en/function.opendir.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60169 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60169&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60169&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60169&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60169&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60169&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60169&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60169&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60169&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#100860) next »