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); } )
Related posts: Podobne posty:
- Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Jak łatwo odmówić dostępu do folderu z htaccess
- 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?
- JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Gdzie mogę znaleźć wszystkie właściwości wszystkich elementów HTML?
- PHP: How to get creation time of file with PHP on Linux machines PHP: Jak uzyskać czas utworzenia pliku z PHP na maszynach Linux
- 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












































