如何控制在目录中读取文件的过程


How to control process of reading file in directory?

我需要写入目录中的所有文件。每个文件的大小约为7mb。

当我打开文件时,我必须解析,保存并打开下一个文件。

我知道这将出现堆栈内存的问题。我怎样才能把这个控制得更优化?

确保在读取每个文件后关闭文件:

$myfile = fopen("webdictionary.txt", "r") or die("Unable to open file!");
echo fread($myfile,filesize("webdictionary.txt"));
fclose($myfile);
// $myfile = // next file
// fclose($myfile)
....