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 Atnaujinimai Via RSS | E-mail Get updates via feedburner Get updates via twitter
Home / Coding / PHP / PHP: Get all files and folde… Pagrindinis / Kodai / PHP / php: Gauti visus failus ir folde ...

PHP: Get all files and folders from a directory (folder) PHP: Gauti visus failus ir aplankus iš katalogo (aplanko)

Posted on 16. Posted on 16. Jun, 2009 by Dragos in Coding , PHP Birželis, 2009 Dragos ir kodavimo, PHP,

To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Gauti visus failus ir aplankus iš katalogo (aplanko) Radau scandir būti puikus sprendimas.

scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir skenuoja kataloge ir grąžina masyvas kuriame visus failus ir katalogus pagal pagrindinį katalogą Mes ieškome in

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. Code bandys pašalinti katalogą, jei elementas yra kataloge arba ištrinti failo, jei atitinkamai elemento failą.

 $lookin='./home/folder'; $ lookin = '. / home / aplankas "; 
 $elements=scandir($lookin); $ elementai = scandir ($ lookin); 
 foreach($elements as $singleEl) { foreach ($ elementai as $ singleEl) ( 
      if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); if (is_dir ($ lookin .'/'.$ singleEl)) rmdir ($ lookin .'/'.$ singleEl); 
      else kitas 
      unlink($lookin.'/'.$singleEl); Unlink ($ lookin .'/'.$ singleEl); 
 } ) 
Translate this post Translate this post


Related posts: Related posts:

  1. Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & MODREWRITE: Kaip lengvai neleisti susipažinti su aplanko su htaccess
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Kaip gauti indeksą (pozicijos grupės) su jQuery objektas?
  3. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Kur rasti Visi Ypatybės Visi HTML elementai?
  4. PHP: How to get creation time of file with PHP on Linux machines PHP: Kaip sukurti laiko Bylos su PHP Linux mašinos
  5. Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script WordPress: Geriausios SEO iTranslator wordpress, gauti nemokamą srautą visiškai automatizuota įjungti scenarijų

    blog comments powered by Disqus Dienoraštis komentarus maitina Disqus