PHP: Get all files and folders from a directory (folder) PHP: Отримати всі файли і папки з каталогу (каталог)
Posted on 16. Опублікований 16. Jun, 2009 by Dragos in Coding , PHP Червень, 2009 Dragos в кодування, PHP
To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Щоб отримати всі файли і папки з директорії (папки) я знайшов scandir буде ідеальним рішенням.
scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir сканує директорії і повертає масив, що містить всі файли і каталоги відповідно до батьківського каталогу ми шукаємо дюйма
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. Код спробує видалити каталог, якщо елемент довідника або видалити файл, якщо, відповідно, елементом якого є файлом.
$lookin='./home/folder'; Lookin $ = '. / Головна / папку'; $elements=scandir($lookin); $ Елементів scandir = ($ Lookin); foreach($elements as $singleEl) { FOREACH ($ елементів при $ singleEl) ( if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); якщо (is_dir ($ Lookin .'/'.$ singleEl)) RMDIR ($ Lookin .'/'.$ singleEl); else ще unlink($lookin.'/'.$singleEl); від'єднати ($ Lookin .'/'.$ singleEl); } )
Related posts: Схожі повідомлення:
- Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Як легко відмовити в доступі до папки з Htaccess
- JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Як отримати індекс (позиція в групі) об'єкта з JQuery?
- JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Де мені знайти властивості для всіх елементів HTML?
- PHP: How to get creation time of file with PHP on Linux machines PHP: Як отримати час створення файлу з PHP на комп'ютерах Linux
- Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Кращі SEO iTranslator для WordPress, отримати безкоштовний трафік з повністю автоматизованої плагіна сценарію












































