PHP: Get all files and folders from a directory (folder) PHP: Получить все файлы и папки из каталога (каталог)
Posted on 16. Опубликованный 16. Jun, 2009 by Dragos in Coding , PHP Июн, 2009 Dragos в кодирование, PHP
To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Чтобы получить все файлы и папки из директории (папке) я нашел scandir будет идеальным решением.
scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir сканирует директории и возвращает массив, содержащий все файлы и каталоги в соответствии с родительского каталога мы ищем дюйма
The code below will try to remove a directory, if the element is a directory or delete a file, if respectively the element is a file. Код попытается удалить каталог, если элемент справочника или удалить файл, если, соответственно, элементом которого является файлом.
$lookin='./home/folder'; Lookin $ = '. / главная / папку'; $elements=scandir($lookin); $ элементов scandir = ($ Lookin); foreach($elements as $singleEl) { FOREACH ($ элементов при $ singleEl) ( if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); если (is_dir ($ Lookin .'/'.$ singleEl)) RMDIR ($ Lookin .'/'.$ singleEl); else еще unlink($lookin.'/'.$singleEl); отменить связь ($ Lookin .'/'.$ singleEl); } )
Related posts: Похожие сообщения:
- Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Как легко отказать в доступе к папке с Htaccess
- JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Как получить индекс (позиция в группе) объекта с JQuery?
- JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Где мне найти свойства для всех элементов HTML?
- PHP: How to get creation time of file with PHP on Linux machines PHP: Как получить время создания файла с PHP на компьютерах Linux
- Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Лучшие SEO iTranslator для WordPress, получить бесплатный трафик с полностью автоматизированной плагина сценария












































