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 MISES A JOUR VIA RSS | Email Get updates via feedburner Get updates via twitter
Home / Coding / PHP / PHP: Get all files and folde… Accueil / Codage / PHP / PHP: Obtenir tous les fichiers et folde ...

PHP: Get all files and folders from a directory (folder) PHP: Obtenir tous les fichiers et dossiers à partir d'un répertoire (dossier)

Posted on 16. Posté le 16. Jun, 2009 by Dragos in Coding , PHP Jun, 2009 par Dragos en codage, PHP

To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Pour obtenir tous les fichiers et dossiers d'un répertoire (dossier) J'ai trouvé scandir être la solution parfaite.

scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir scanne un répertoire et retourne un tableau contenant tous les fichiers et répertoires sous le répertoire parent nous recherchons po

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. Le code ci-dessous vous essayez de supprimer un répertoire, si l'élément est un annuaire ou supprimer un fichier, si, respectivement, l'élément est un fichier.

 $lookin='./home/folder'; lookin $ = '. / home / dossier'; 
 $elements=scandir($lookin); $ elements = scandir (Lookin $); 
 foreach($elements as $singleEl) { éléments foreach ($ as $ singleEl) ( 
      if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); if (is_dir ($ lookin .'/'.$ singleEl)) rmdir ($ lookin .'/'.$ singleEl); 
      else autre 
      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: Comment nier facilement accès à un dossier avec htaccess
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Comment obtenir l'index (la position dans un groupe) d'un objet avec jQuery?
  3. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Où puis-je trouver toutes les propriétés à tous les éléments HTML?
  4. PHP: How to get creation time of file with PHP on Linux machines PHP: Comment avoir le temps de création du fichier de PHP sur des machines Linux
  5. Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Best iTranslator SEO pour Wordpress, obtenir du trafic gratuit à partir du script entièrement automatisé plugin

    blog comments powered by Disqus Commentaires Blog powered by Disqus