Recursively reads the directory structure into an array and saves the directory structure novice PHP
$arr _dir = Array ();
$path = './';
Recursively reads the directory structure into an array and saves the directory structure
function MakeDir ($path,& $arr)
{
$dir = Opendir ($path);
while (($file =readdir ($dir))!==false)
{
if ($file! = '. ') && $file! = ' ... ')
{
Var_dump ($file);
if (!is_dir ($path. ' /'. $file))
{
$arr [] = $file;
}
Else
{
MakeDir ($path. ' /'. $file, $arr [$file]);
}
}
}
Closedir ($dir);
}
MakeDir ($path, $arr _dir);
Var_dump ($arr _dir);
?>
------Solution--------------------
What's the problem?
------Solution--------------------
------Solution--------------------
Thought you were having a problem. The Wolf is coming ...
------Solution--------------------
Isn't it easy to use iterators?
$p = './';
$ite = new Recursivedirectoryiterator ($p);
foreach (New Recursiveiteratoriterator ($ite) as $filename = + $cur) {
if (Is_dir ($filename)) continue;
$res [] = $filename;
}
Print_r ($res);