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