PHP: Get all files and folders from a directory (folder) PHP: Get všech souborů a složek z adresáře (složky)
Posted on 16. Publikováno dne 16. Jun, 2009 by Dragos in Coding , PHP Června 2009 od Dragos v Kódování, PHP
To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Chcete-li získat všechny soubory a složky z adresáře (složky) scandir jsem zjistil, že je perfektním řešením.
scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir skenuje adresáře a vrací pole obsahující všechny soubory a adresáře v nadřazeném adresáři hledáme palců
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. Kód se bude snažit odstranit adresář, pokud element je adresář nebo smazat soubor, respektive pokud element je soubor.
$lookin='./home/folder'; Hledal $ = '. / home / adresář'; $elements=scandir($lookin); $ prvky = scandir ($ Hledal); foreach($elements as $singleEl) { foreach ($ prvky as $ singleEl) ( if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); if (is_dir ($ hledal .'/'.$ singleEl)) rmdir ($ hledal .'/'.$ singleEl); else jiné unlink($lookin.'/'.$singleEl); unlink ($ hledal .'/'.$ singleEl); } )
Related posts: Související příspěvky:
- Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Jak jednoduše zakázat přístup do složky s htaccess
- JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Jak se dostat na indexu (pozici v rámci skupiny) z objektu s jQuery?
- JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Kde najdu všechny vlastnosti pro všechny prvky HTML?
- PHP: How to get creation time of file with PHP on Linux machines PHP: Jak získat čas vytvoření souboru s PHP na strojích Linux
- Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Nejlepší iTranslator SEO pro Wordpress, dostanete zdarma plně automatizovaný provoz od plugin skript












































