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 Aktualisierungen per RSS | E-Mail Get updates via feedburner Get updates via twitter
Home / Coding / PHP / PHP: Get all files and folde… Home / Programmierung / PHP / PHP: Erhalten Sie alle Dateien und folde ...

PHP: Get all files and folders from a directory (folder) PHP: Holen Sie sich alle Dateien und Ordner aus einem Verzeichnis (Ordner)

Posted on 16. Gesendet am 16. Jun, 2009 by Dragos in Coding , PHP Juni 2009 von Dragos in Coding, PHP

To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Um alle Dateien und Ordner aus einem Verzeichnis (Ordner) Ich habe scandir werden die perfekte Lösung.

scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir scannt ein Verzeichnis und gibt ein Array mit allen Dateien und Verzeichnisse unter das übergeordnete Verzeichnis, die wir suchen 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. Der folgende Code wird versuchen, ein Verzeichnis zu entfernen, wenn das Element ist ein Verzeichnis oder eine Datei löschen, bzw. wenn das Element ist eine Datei.

 $lookin='./home/folder'; $ lookin = '. / home / Ordner'; 
 $elements=scandir($lookin); $ elements = scandir ($ lookin); 
 foreach($elements as $singleEl) { foreach ($ elements as $ singleEl) ( 
      if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); if (is_dir ($ lookin .'/'.$ singleEl)) rmdir ($ lookin .'/'.$ singleEl); 
      else sonst 
      unlink($lookin.'/'.$singleEl); unlink ($ lookin .'/'.$ singleEl); 
 } ) 
Translate this post Translate this post


Related posts: In Verbindung stehende Pfosten:

  1. Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Wie leicht verhindern den Zugriff auf einen Ordner mit htaccess
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Wie in den Index zu erhalten (Position innerhalb einer Gruppe) eines Objekts mit jQuery?
  3. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Wo finde ich alle Eigenschaften für alle HTML-Elemente?
  4. PHP: How to get creation time of file with PHP on Linux machines PHP: Wie man die Schaffung Zeitpunkt der Datei mit PHP auf Linux-Maschinen zu erhalten
  5. Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Best SEO iTranslator für Wordpress, erhalten freien Verkehr von vollautomatischen Plugin-Skript

    blog comments powered by Disqus Blog-Kommentare powered by Disqus