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 Updates via RSS | E-post Get updates via feedburner Get updates via twitter
Home / Coding / PHP / PHP: Get all files and folde… Avaleht / kodeerimise / PHP / PHP: Get kõik failid ja folde ...

PHP: Get all files and folders from a directory (folder) PHP: Get kõik failid ja kaustad kataloogi (kausta)

Posted on 16. Postitatud 16. Jun, 2009 by Dragos in Coding , PHP Juuni, 2009 Dragos in kodeerimise, PHP

To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Et saada kõik failid ja kaustad kataloogi (kausta) ma leidsin scandir olla parim lahendus.

scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir otsib kataloog ja tagastab massiivi, mis sisaldab kõigi failide ja kataloogide alusel Parent Directory Otsime sisse

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. Kood püüab eemaldada kataloogi, kui element on kataloog või kustutada faili, kui vastavalt elemendi faili.

 $lookin='./home/folder'; $ otsisime = '. / home / kaust';
$elements=scandir($lookin); $ osad = scandir ($ otsisime);
foreach($elements as $singleEl) { foreach ($ elemente $ singleEl) (
     if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); if (is_dir ($ otsisime .'/'.$ singleEl)) rmdir ($ otsisime .'/'.$ singleEl);
     else muu
     unlink($lookin.'/'.$singleEl); linkida ($ otsisime .'/'.$ singleEl);
} ) 
Translate this post Tõlgi see postitus


Related posts: Seonduvad postitused:

  1. Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Kuidas lihtne keelata juurdepääsu kausta htaccess
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? Javascript: Kuidas saada indeks (seisukoha rühma) objekti jQuery?
  3. JavaScript: Where do I Find All Properties for All HTML Elements ? Javascript: Kust leida kõik omadused Kõik HTML elemendid?
  4. PHP: How to get creation time of file with PHP on Linux machines PHP: Kuidas loomise ajal faili PHP Linux masinatega
  5. Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Best SEO iTranslator WordPress, tasuta liiklus täielikult automatiseeritud plugin script

    blog comments powered by Disqus blog comments powered by Disqus