以下のスクリプトでは、$baseフォルダー内のフォルダーとファイルを反復処理しようとしています。単一レベルの子フォルダーが含まれ、それぞれに多数の.txtファイルが含まれている(サブフォルダーは含まれていない)と思います。
以下のコメントの要素を参照する方法を理解する必要があります...
どんな助けでも大歓迎です。私はこれをまとめるのに本当に近いです:-)
$base = dirname(__FILE__).'/widgets/';
$rdi = new RecursiveDirectoryIterator($base);
foreach(new RecursiveIteratorIterator($rdi) as $files_widgets)
{
if ($files_widgets->isFile())
{
$file_name_widget = $files_widgets->getFilename(); //what is the filename of the current el?
$widget_text = file_get_contents(???); //How do I reference the file here to obtain its contents?
$sidebar_id = $files_widgets->getBasename(); //what is the file's parent directory name?
}
}