Вот черновой скрипт, который сее генерирует:
Код: Выделить всё
function mediafound($dir){
$files = scandir($dir);
$size = count($files);
$i=2;
while ( $i < $size ){
if (is_dir($dir."/".$files[$i])) {
$stat_file = "dir";
};
if (is_file($dir."/".$files[$i])) {
$stat_file = "file";
};
$type="type=".$stat_file." ".$files[$i];
echo $type."<br>";
$dir_0[$i-2] = $type;
$mediafound[$i-2][0] = $type;
$i++;
};
echo "<br>";
$i=0;
while ( $i < count($dir_0)){
echo $dir_0[$i]."<br>";
$i++;
};
echo "<br>";
$dir_n=0;
$i=0;
while ( $i < count($dir_0)){
$file_n = $dir_0[$i];
$file_n_l = strlen($file_n);
if ( substr($file_n, 5, 3) == "dir" ){
echo $dir_n.": ".substr($file_n, 9, $file_n_l-8)."<br>";
$dir_list[$dir_n] = substr($file_n, 9, $file_n_l-8);
$dir_n++;
};
$i++;
};
echo "<br>";
$i=0;
while ( $i <count($dir_list)){
echo $dir_list[$i]."<br>";
$i++;
};
echo "<br>";
$n = count($dir_list);
$i=0;
while ( $i < $n ){
$cat = $dir."/".$dir_list[$i];
$files_list = scandir($cat);
$f=0;
$n_f = count($files_list);
while ( $f < $n_f ){
echo $files_list[$f]."<br>";
$mediafound[$f][$i+1] = $files_list[$f];
$f++;
};
$i++;
};
echo "<br>";
return $mediafound;
};