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 Ažuriranja putem RSS | E-mail Get updates via feedburner Get updates via twitter
Home / Coding / PHP / PHP: Get all files and folde… Home / Kodiranje / PHP / PHP: Saznajte sve datoteke i folde ...

PHP: Get all files and folders from a directory (folder) PHP: Saznajte sve datoteke i mape iz direktorija (mapa)

Posted on 16. Poslano na 16. Jun, 2009 by Dragos in Coding , PHP Jun, 2009 by Dragos u kodiranju, PHP

To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Da biste dobili sve datoteke i mape iz direktorija (mape) Našao sam scandir biti idealno rješenje.

scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir skenira direktorij i vraća niz koji sadrži sve datoteke i direktorije pod Parent Directory we're 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. Kod ispod će pokušati ukloniti direktorij, ako je element direktorija ili izbrisati datoteku, ako odnosno element je datoteka.

 $lookin='./home/folder'; $ lookin = '. / home / mapu'; 
 $elements=scandir($lookin); $ elementi scandir = ($ lookin); 
 foreach($elements as $singleEl) { foreach ($ $ elemenata kao singleEl) ( 
      if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); if (is_dir ($ lookin .'/'.$ singleEl)) rmdir ($ lookin .'/'.$ singleEl); 
      else drugi 
      unlink($lookin.'/'.$singleEl); otkačiti ($ lookin .'/'.$ singleEl); 
 } ) 
Translate this post Translate this post


Related posts: Related posts:

  1. Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Kako jednostavno onemogućiti pristup do mape s htaccess
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Kako biste dobili indeks (poziciju unutar grupe) s jQuery objekt?
  3. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Gdje mogu pronaći Sve nekretnine za sve HTML elemenata?
  4. PHP: How to get creation time of file with PHP on Linux machines PHP: Kako doći vrijeme stvaranja datoteke sa PHP na Linux strojevima
  5. Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Best SEO iTranslator za Wordpress, dobiti slobodan promet iz potpuno automatizirana skripta čep

    blog comments powered by Disqus Blog komentari powered by Disqus