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 Aktualizáciou cez RSS | E-mail Get updates via feedburner Get updates via twitter
Home / Coding / PHP / PHP: Get all files and folde… Home / Kódovanie / PHP / PHP: Získať všetky súbory a folde ...

PHP: Get all files and folders from a directory (folder) PHP: Get všetkých súborov a priečinkov z adresára (zložky)

Posted on 16. Publikované dňa 16. Jun, 2009 by Dragos in Coding , PHP Júna 2009 od Dragos v Kódovanie, PHP

To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Ak chcete získať všetky súbory a priečinky z adresára (zložky) scandir som zistil, že je perfektným rieš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ára a vracia pole obsahujúce všetky súbory a adresáre v nadradených adresári hľadáme palcov

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 sa bude snažiť odstrániť adresár, ak element je adresár alebo zmazať súbor, respektíve ak element je súbor.

 $lookin='./home/folder'; Hľadal $ = '. / Home / adresár';
$elements=scandir($lookin); $ Prvky = scandir ($ Hľadal);
foreach($elements as $singleEl) { foreach ($ prvky as $ singleEl) (
     if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); if (is_dir ($ hľadal .'/'.$ singleEl)) rmdir ($ hľadal .'/'.$ singleEl);
     else iné
     unlink($lookin.'/'.$singleEl); unlink ($ hľadal .'/'.$ singleEl);
} ) 
Translate this post Translate this post


Related posts: Súvisiace príspevky:

  1. Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Ako jednoducho zakázať prístup do priečinka s htaccess
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Ako sa dostať na indexe (pozíciu v rámci skupiny) z objektu s jQuery?
  3. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Kde nájdem všetky vlastnosti pre všetky prvky HTML?
  4. PHP: How to get creation time of file with PHP on Linux machines PHP: Ako získať čas vytvorenia súboru s PHP na strojoch Linux
  5. Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Najlepšie iTranslator SEO pre Wordpress, dostanete zadarmo plne automatizovaný prevádzku od plugin skript

    blog comments powered by Disqus blog pripomienky powered by Disqus