I used following code to scan & list directory contents (including all
subdirectories) . It turns out that subdirectories are NOT recognized as
directories when the function is called in a recursive way.
In other words when function scans a subdirectory no directories inside are
recognised as directories therefore it cannot scan ti's contents.
<?php
$directory = "/www/prawnik/";
function list_dir($dir) {
if ($handle = opendir($dir)) {
static $indent = 2;
echo "indent=$indent <br>";
echo "dir=$dir<b r>";
while (false !== ($file = readdir($handle ))) {
if ($file=="." || $file =="..") continue;
if (is_dir($file)= ='dir') {
$indent++;
/*
for ($index=1; $index<=$indent ; $index++) {
echo "   ";
};
*/
echo "<B>$file:".fil etype($dir)."</B><br>";
$newdir = $dir.$file."/";
list_dir ($newdir);
$indent--;
} else echo "$indent:$file< br>";
}
closedir($handl e);
}
}
list_dir ($directory);
?>
subdirectories) . It turns out that subdirectories are NOT recognized as
directories when the function is called in a recursive way.
In other words when function scans a subdirectory no directories inside are
recognised as directories therefore it cannot scan ti's contents.
<?php
$directory = "/www/prawnik/";
function list_dir($dir) {
if ($handle = opendir($dir)) {
static $indent = 2;
echo "indent=$indent <br>";
echo "dir=$dir<b r>";
while (false !== ($file = readdir($handle ))) {
if ($file=="." || $file =="..") continue;
if (is_dir($file)= ='dir') {
$indent++;
/*
for ($index=1; $index<=$indent ; $index++) {
echo "   ";
};
*/
echo "<B>$file:".fil etype($dir)."</B><br>";
$newdir = $dir.$file."/";
list_dir ($newdir);
$indent--;
} else echo "$indent:$file< br>";
}
closedir($handl e);
}
}
list_dir ($directory);
?>