note 29671 deleted from function.glob by aidan
| From: | aidan@php.net | Date: | Thu, 09 Dec 2004 03:43:17 +0000 |
| Subject: | note 29671 deleted from function.glob by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-81563@lists.php.net to get a copy of this message | ||
Note Submitter: darkmare dot n dot ospam at interaccess dot cl
----
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 :) )