PHP: Get all files and folders from a directory (folder) PHP: Get kollha fajls u folders minn direttorju (folder)
Posted on 16. Posted on 16. Jun, 2009 by Dragos in Coding , PHP Ġunju, 2009 minn Dragos fl-Kodifika, PHP
To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Biex tikseb l-fajls u folders minn direttorju (folder) I scandir misjuba li tkun is-soluzzjoni perfetta.
scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir scans f'direttorju u jirritorna l-firxa li fiha l-fajls kollha u direttorji taħt il-direttorju parent we're tfittex pulzieri
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-kodiċi hawn taħt ser tipprova tneħħi direttorju, jekk l-element huwa direttorju jew iħassar il-fajl, rispettivament jekk l-element huwa fajl.
$lookin='./home/folder'; dar $ lookin = ". / / folder"; $elements=scandir($lookin); elementi $ = scandir ($ lookin); foreach($elements as $singleEl) { ($ elementi foreach bħala $ singleEl) ( if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); jekk (is_dir ($ lookin .'/'.$ singleEl)) rmdir ($ lookin .'/'.$ singleEl); else ieħor unlink($lookin.'/'.$singleEl); unlink ($ lookin .'/'.$ singleEl); } )
Related posts: Related postijiet:
- Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Kif faċilment jiċħad l-aċċess għal folder ma htaccess
- JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Kif tista 'tikseb l-indiċi (il-pożizzjoni fi ħdan grupp) ta' oġġett jQuery?
- JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Fejn nista Find All Properties for All Elementi HTML?
- PHP: How to get creation time of file with PHP on Linux machines PHP: Kif tikseb ħin ħolqien tal-fajl ma PHP fuq magni Linux
- Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Best SEO iTranslator għall Wordpress, ġib it-traffiku ħieles mill-iskrittura plugin totalment awtomatizzati












































