fucntion getFileNames($root)
{
$out = array();
$files = scandir($root);
for ($i = 0; $i < count($files); $i++)
{
$name = $files[$i];
if ($name == "." || $name == "..")
{
continue;
}
if (is_dir($root . "/" . $name))
{
$out = array_merge($out, getFileNames($root . "/" . $name));
}
else
{
$out[] = $name;
}
}
return $out;
}
версия без рекурсии
function convertArray($array, $path)
{
$result = array();
for ($i = 0; $i < count($array); $i++)
{
$result[] = $path . "/" . $array[$i];
}
return $result;
}
fucntion getFileNames($root)
{
$out = array();
$files = convertArray(scandir($root), $root);
while (count($files))
{
$path = array_shift($files);
if (basename($path) == "." || basename($path) == "..")
{
continue;
}
if (is_dir($path))
{
$files = array_merge($files, convertArray(scandir($path), $path);)
}
else
{
$out[] = basename($name);
}
}
return $out;
}