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 FRISSÍTÉSEK VIA RSS | E-mail Get updates via feedburner Get updates via twitter
Home / Coding / PHP / PHP: Get all files and folde… Home / Coding / PHP / PHP: Get összes fájlt és folde ...

PHP: Get all files and folders from a directory (folder) PHP: Vedd meg a fájlok és mappák egy könyvtár (mappa)

Posted on 16. Posted on 16. Jun, 2009 by Dragos in Coding , PHP Június, 2009 Dragos a Coding, PHP

To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Ahhoz, hogy fájlok és mappák egy könyvtár (mappa) Találtam scandir, hogy a tökéletes megoldás.

scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir vizsgál egy könyvtárat és egy tömbbel tér vissza, amely az összes fájlt és könyvtárat a szülő könyvtár keresünk hüvelyk

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. Az alábbi kód megpróbálja eltávolítani egy könyvtárat, ha az elem egy könyvtárat vagy egy fájlt törölni, illetve ha az elem egy fájlt.

 $lookin='./home/folder'; $ keresem = '. / home / mappa ";
$elements=scandir($lookin); $ elements = scandir ($ keresem);
foreach($elements as $singleEl) { foreach ($ elemek as $ singleEl) (
     if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); if (is_dir ($ keresem .'/'.$ singleEl)) rmdir ($ keresem .'/'.$ singleEl);
     else vagy
     unlink($lookin.'/'.$singleEl); unlink ($ keresem .'/'.$ 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: Hogyan lehet egyszerűen megtagadja a hozzáférést egy mappát htaccess
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Hogyan juthat az index (position csoportján belül) egy objektum jQuery?
  3. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Hol találok Minden tulajdonság minden HTML elemek?
  4. PHP: How to get creation time of file with PHP on Linux machines PHP: How to get létrehozásakor a fájl a PHP Linux gépek
  5. Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Best SEO iTranslator a Wordpress, ingyenes forgalmat a teljesen automatizált plugin script

    blog comments powered by Disqus iPhone Disqus szerint