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 UPDATES VIA RSS | E-pasts Get updates via feedburner Get updates via twitter
Home / Coding / PHP / PHP: Get all files and folde…

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);
} ) 
Translate this post Tulkot šo ziņu


Related posts: Related posts:

  1. Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Kā viegli liegt mapē ar htaccess
  2. 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?
  3. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Kur es varu atrast visas Properties visiem HTML elementiem?
  4. 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
  5. 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

    blog comments powered by Disqus blog komentāriem powered by Disqus