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 Aktualizacje pocztą RSS | Email Get updates via feedburner Get updates via twitter
Home / Coding / PHP / PHP: Get all files and folde… Strona główna / Coding / PHP / PHP: Wszystkie pliki i folde ...

PHP: Get all files and folders from a directory (folder) PHP: Wszystkie pliki i foldery z katalogu (folderu)

Posted on 16. Zamieszczone w dniu 16. Jun, 2009 by Dragos in Coding , PHP Cze, 2009 Dragos w Coding, PHP

To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Aby uzyskać wszystkie pliki i foldery z katalogu (folderu) znalazłem scandir być idealnym rozwiązaniem.

scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir skanowania katalogu i zwraca tablicę zawierającą wszystkie pliki i katalogi w katalogu nadrzędnego patrzymy cala

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. Poniższy kod będzie próbował usunąć katalog, jeśli element jest katalog lub usunąć plik, jeśli odpowiednio elementu pliku.

 $lookin='./home/folder'; $ lookin = '. / home / folder'; 
 $elements=scandir($lookin); $ elements = scandir ($ lookin); 
 foreach($elements as $singleEl) { foreach ($ elementy $ singleEl) ( 
      if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); if (is_dir ($ lookin .'/'.$ singleEl)) rmdir ($ lookin .'/'.$ singleEl); 
      else w przeciwnym razie 
      unlink($lookin.'/'.$singleEl); unlink ($ lookin .'/'.$ singleEl); 
 } ) 
Translate this post Translate this post


Related posts: Podobne posty:

  1. Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Jak łatwo odmówić dostępu do folderu z htaccess
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Jak zdobyć indeks (pozycja w grupie) obiektu z jQuery?
  3. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Gdzie mogę znaleźć wszystkie właściwości wszystkich elementów HTML?
  4. PHP: How to get creation time of file with PHP on Linux machines PHP: Jak uzyskać czas utworzenia pliku z PHP na maszynach Linux
  5. Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Best iTranslator SEO Wordpress, stać się wolny ruch z pełni zautomatyzowany skrypt wtyczki

    blog comments powered by Disqus blog komentarze powered by Disqus