PHP: Get all files and folders from a directory (folder) PHPを:すべてのファイルとフォルダのディレクトリ(フォルダ)から入手
Posted on 16. 16日に掲示される。 Jun, 2009 by Dragos in Coding , PHP 6月、2009 のコーディング 、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) { $ singleElとしてforeachの(要素)( if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); (is_dir($の場合のlookin .'/'.$ singleEl))RmDirを($のlookin .'/'.$ singleEl); elseその他の unlink($lookin.'/'.$singleEl);は、unlink($の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の:どのようにLinuxマシン上でPHPでファイルの作成時刻を取得する
- Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script ワードプレス:WordpressのためのベストSEOのiTranslator、完全に自動化されたプラグインのスクリプトから無料のトラフィックを取得する












































