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 Aggiornamenti via RSS | Email Get updates via feedburner Get updates via twitter
Home / Coding / PHP / PHP: Get all files and folde… Home / Coding / PHP / PHP: Ottieni tutti i file e folde ...

PHP: Get all files and folders from a directory (folder) PHP: Ottieni tutti i file e le cartelle da una directory (cartella)

Posted on 16. Posted on 16. Jun, 2009 by Dragos in Coding , PHP Giugno, 2009 da Dragos in Coding, PHP

To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Per ottenere tutti i file e le cartelle da una directory (cartella) ho trovato scandir essere la soluzione perfetta.

scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir scansioni una directory e restituisce un array contenente tutti i file e le directory sotto la directory di padre che stiamo cercando a.

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. Il seguente codice si tenta di rimuovere una directory, se l'elemento è una directory o eliminare un file, rispettivamente, se l'elemento è un file.

 $lookin='./home/folder'; lookin $ = '. / home / cartella'; 
 $elements=scandir($lookin); $ elementi = scandir ($ lookin); 
 foreach($elements as $singleEl) { elementi ($ array as $ singleEl) ( 
      if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); if (is_dir ($ lookin .'/'.$ singleEl)) rmdir ($ lookin .'/'.$ singleEl); 
      else altro 
      unlink($lookin.'/'.$singleEl); unlink ($ lookin .'/'.$ singleEl); 
 } ) 
Translate this post Traduci questo post


Related posts: Related posts:

  1. Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Come facilmente negare l'accesso a una cartella con htaccess
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Come ottenere l'indice (posizione all'interno di un gruppo) di un oggetto con jQuery?
  3. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Dove posso trovare tutte le proprietà di tutti gli elementi HTML?
  4. PHP: How to get creation time of file with PHP on Linux machines PHP: Come ottenere il tempo di creazione del file con PHP su macchine Linux
  5. Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: iTranslator Best SEO per Wordpress, ottenere il traffico gratuito da script plug completamente automatizzato

    blog comments powered by Disqus commenti del blog powered by Disqus