This is a translated page. The original can be found here: http://iwebdevel.com/2009/06/16/php-get-all-files-and-folders-from-a-directory-folder/
UPDATES VIA RSS | Email Обновления через RSS | Email Get updates via feedburner Get updates via twitter
Home / Coding / PHP / PHP: Get all files and folde… Главная / кодирования / PHP / PHP: Получить все файлы и folde ...

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); 
 } ) 
Translate this post Перевести эту должность


Related posts: Похожие сообщения:

  1. Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Как легко отказать в доступе к папке с Htaccess
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Как получить индекс (позиция в группе) объекта с JQuery?
  3. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Где мне найти свойства для всех элементов HTML?
  4. PHP: How to get creation time of file with PHP on Linux machines PHP: Как получить время создания файла с PHP на компьютерах Linux
  5. Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Лучшие SEO iTranslator для WordPress, получить бесплатный трафик с полностью автоматизированной плагина сценария

    blog comments powered by Disqus Блог комментарии сила Disqus