note 29671 added to function.glob

From: Date: Fri, 21 Feb 2003 02:09:45 +0000
Subject: note 29671 added to function.glob
Groups: php.notes 
Request: Send a blank email to php-notes+get-44283@lists.php.net to get a copy of this message
working with a web access to a private folder outside the webserver's permision, I needed to list the subdirectories in the following form with a function that recieve "c:\\windows" as the only argument. \sub1 \sub2 \sub2\another1 \sub2\another2 etc... About an hour of testing gave me the 'glob_it' function! ;), use it or modify it at will. Hope it helps someone. I use PHP 4 under WIN98SE with APACHE. *** BEGGINING function glob_it($directory) { // EXAMPLE: $directory = "C:\\windows" foreach (glob(str_replace("\\", "/", $directory) . "/*") as $filename) { if(is_dir($filename)) { $dirs[] = $filename; $dirs_aux = glob_it(str_replace("/", "\\", $filename)); for($i=0; $i<sizeof($dirs_aux); $i++) { $dirs[] = $dirs_aux[$i]; } } } Return @$dirs; } *** END Sorry about the english and the apparently messedup code... it looked good on EditPlus (which RULES by the way :) ) -- http://www.php.net/manual/en/function.glob.php http://master.php.net/manage/user-notes.php?action=edit+29671 http://master.php.net/manage/user-notes.php?action=delete+29671 http://master.php.net/manage/user-notes.php?action=reject+29671

« previous php.notes (#44283) next »