Re: HELP: Print directory structure.
| From: | Daniel Beulshausen | Date: | Tue, 15 May 2001 16:36:03 +0000 |
| Subject: | Re: HELP: Print directory structure. | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-7584@lists.php.net to get a copy of this message | ||
At 16:10 15.05.2001 +0200, Alessio Bernesco Làvore wrote:
Could someone help me, please? I have to build a recursive function that print to video all the directories (and sub-directories and so on...) names presents in a specified sub-directory on the server. I can't handle that function, please, i'm in panic...you can use something like the following <?php function dir_to_array($dir = "./") { $realpath = realpath($dir); if(!($dir = @dir($realpath))) {
return false;} $retval = array(); $ignore = array("." => true, ".." => true); while($raw = $dir->read()) {
if($ignore[$raw]) {
continue;
}
$entry = $realpath . "\\" . $raw;
if(!is_dir($entry)) {
$readable = is_readable($entry) ? 1 : 0;
$writeable = is_writeable($entry) ? 2 : 0;
$retval[$raw] = $readable | $writeable;
} else {
$retval[$raw] = dir_to_array($entry);
}
}
return $retval;
}
$array = dir_to_array("../");
print_r($array);
?>
daniel
/*--
daniel beulshausen - daniel@php4win.de
using php on windows? http://www.php4win.de