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); } )
Related posts: Related posts:
- Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Come facilmente negare l'accesso a una cartella con htaccess
- 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?
- JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Dove posso trovare tutte le proprietà di tutti gli elementi HTML?
- 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
- 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












































