【发布时间】:2016-08-03 00:18:10
【问题描述】:
我正在使用此代码输出目录中文件的内容,但我有两个问题
首先是该目录包含子目录并且此代码不输出 这些子目录中的文件内容
第二个问题 我希望这段代码输出像
文件名:"文件名" 内容:“文件内容” 这样我就可以解析这个
$dir = new DirectoryIterator('./Chemistry');
foreach($dir as $file)
{
if(!$file->isDot() && $file->isFile() && strpos($file->getFilename(), '.md') !== false)
{
$content = file_get_contents($file->getPathname());
echo $content
}
}
?>
【问题讨论】:
标签: php loops directory file-get-contents subdirectory