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 Aktualizací přes RSS | E-mail Get updates via feedburner Get updates via twitter
Home / Coding / PHP / PHP: Get all files and folde… Home / Kódování / PHP / PHP: Získat všechny soubory a folde ...

PHP: Get all files and folders from a directory (folder) PHP: Get všech souborů a složek z adresáře (složky)

Posted on 16. Publikováno dne 16. Jun, 2009 by Dragos in Coding , PHP Června 2009 od Dragos v Kódování, PHP

To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Chcete-li získat všechny soubory a složky z adresáře (složky) scandir jsem zjistil, že je perfektním řešením.

scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir skenuje adresáře a vrací pole obsahující všechny soubory a adresáře v nadřazeném adresáři hledáme palců

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. Kód se bude snažit odstranit adresář, pokud element je adresář nebo smazat soubor, respektive pokud element je soubor.

 $lookin='./home/folder'; Hledal $ = '. / home / adresář'; 
 $elements=scandir($lookin); $ prvky = scandir ($ Hledal); 
 foreach($elements as $singleEl) { foreach ($ prvky as $ singleEl) ( 
      if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); if (is_dir ($ hledal .'/'.$ singleEl)) rmdir ($ hledal .'/'.$ singleEl); 
      else jiné 
      unlink($lookin.'/'.$singleEl); unlink ($ hledal .'/'.$ singleEl); 
 } ) 
Translate this post Translate this post


Related posts: Související příspěvky:

  1. Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Jak jednoduše zakázat přístup do složky s htaccess
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Jak se dostat na indexu (pozici v rámci skupiny) z objektu s jQuery?
  3. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Kde najdu všechny vlastnosti pro všechny prvky HTML?
  4. PHP: How to get creation time of file with PHP on Linux machines PHP: Jak získat čas vytvoření souboru s PHP na strojích Linux
  5. Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Nejlepší iTranslator SEO pro Wordpress, dostanete zdarma plně automatizovaný provoz od plugin skript

    blog comments powered by Disqus blog připomínky powered by Disqus