PHP: Get all files and folders from a directory (folder) PHP: Get visus failus un mapes no direktorijā (mapē)
Posted on 16. Posted on 16. Jun, 2009 by Dragos in Coding , PHP Jun, 2009 by Dragos in kodēšanas, PHP
To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Lai saņemtu visus failus un mapes no direktorija (mape) Es atklāju scandir ir ideāls risinājums.
scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir skenē direktoriju un atgriež masīvu, kas satur visus failus un direktorijas zem Parent Directory mēs looking 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. Kodu zemāk centīsies noņemt direktorijā, ja elements ir direktorijā vai dzēst failu, ja attiecīgi elements failu.
$lookin='./home/folder'; $ lookin = '. / home / mape'; $elements=scandir($lookin); $ elementi = scandir ($ lookin); foreach($elements as $singleEl) { foreach ($ elementus kā $ singleEl) ( if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); if (is_dir ($ lookin .'/'.$ singleEl)) rmdir ($ lookin .'/'.$ singleEl); else citādi unlink($lookin.'/'.$singleEl); atvienot ($ lookin .'/'.$ singleEl); } )
Related posts: Related posts:
- Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Kā viegli liegt mapē ar htaccess
- JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Kā nokļūt indekss (amatu grupā) un objekts ar jQuery?
- JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Kur es varu atrast visas Properties visiem HTML elementiem?
- PHP: How to get creation time of file with PHP on Linux machines PHP: Kā nokļūt creation time of failu ar PHP uz Linux mašīnām
- Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Best SEO iTranslator uz WordPress, bezmaksas satiksme pilnībā automatizētu spraudnis script












































