Главная > Программирование > PHP Рекурсивное чтение каталоговПример 1function read_folder($folder) { $files = scandir($folder); foreach($files as $file) { if ($file == '.' || $file == '..') continue; $fullfilename = $folder . '/' . $file; echo $fullfilename . '<br>'; if (is_dir($fullfilename)) read_folder($fullfilename); } } read_folder('./myfolder'); Пример 2function dir_path($dir) { $dh = opendir($dir); $path_curent = ''; while (($file = readdir($dh)) !== false) if ($file != "." and $file != "..") { $path = $dir."/".$file; if (is_dir($path)) { $path_curent .= "$path"."<br>"; $path_curent .= dir_path($path); } /* можно и файлы else { if (is_file($path)) { $path_curent .= "$path"."<br>"; } } */ } closedir($dh); return $path_curent; } echo dir_path('./smarty'); Функция копирования директории со всеми вложениями<?php Главная > Программирование > PHP |