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 - [EMAIL PROTECTED]
using php on windows? http://www.php4win.de
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]