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 Päivitykset RSS | Sähköposti Get updates via feedburner Get updates via twitter
Home / Coding / PHP / PHP: Get all files and folde… Etusivu / koodaus / PHP / PHP: Hanki kaikki tiedostot ja folde ...

PHP: Get all files and folders from a directory (folder) PHP: Hanki kaikki tiedostot ja kansiot hakemisto (kansio)

Posted on 16. Postitettu 16. Jun, 2009 by Dragos in Coding , PHP Kesäkuu, 2009 Dragos vuonna Coding, PHP

To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Saada kaikki tiedostot ja kansiot hakemisto (kansio) Löysin scandir on täydellinen ratkaisu.

scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir lukee hakemisto ja palauttaa taulukko sisältää kaikki tiedostot ja hakemistot mukaisesti Parent Directory Etsimme sisään

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. Oheinen koodi yrittää poistaa hakemiston, jos tekijä on hakemisto tai poistaa tiedoston, jos vastaavasti elementti on tiedosto.

 $lookin='./home/folder'; $ Lookin = '. / home / kansio'; 
 $elements=scandir($lookin); $ osat = scandir ($ lookin); 
 foreach($elements as $singleEl) { foreach ($ elementtejä kuten $ singleEl) ( 
      if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); jos (is_dir ($ lookin .'/'.$ singleEl)) rmdir ($ lookin .'/'.$ singleEl); 
      else muuten 
      unlink($lookin.'/'.$singleEl); unlink ($ lookin .'/'.$ singleEl); 
 } ) 
Translate this post Käännä tämä viesti


Related posts: Liittyvien virkojen:

  1. Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Kuinka helposti kieltää pääsy kansion htaccess
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Miten saada indeksi (asema ryhmä) objektin kanssa jQuery?
  3. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Mistä löydän kaikki ominaisuudet kaikki HTML-elementit?
  4. PHP: How to get creation time of file with PHP on Linux machines PHP: Miten saada luomisen aika tiedoston PHP Linux-koneiden
  5. Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Best SEO iTranslator Wordpress, saat ilmaisen liikenteen täysin automatisoitu plugin script

    blog comments powered by Disqus blogin kommentit powered by Disqus