Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
下一个文件是在PHP中第一个文件完成之前创建的?_Php_File_Buffer_Fopen_Fputs - Fatal编程技术网

下一个文件是在PHP中第一个文件完成之前创建的?

下一个文件是在PHP中第一个文件完成之前创建的?,php,file,buffer,fopen,fputs,Php,File,Buffer,Fopen,Fputs,在Php中,我编写了如下代码 //Example Code foreach($arrayitem as $arr) //$arrayitem is having some array data { $fp=fopen($arr.'.xls','w'); for(condition) { //here i'm getting full content of an webpage(huge data) and some regexp to match data preg_matc

在Php中,我编写了如下代码

//Example Code

foreach($arrayitem as $arr) //$arrayitem is having some array data
{
 $fp=fopen($arr.'.xls','w');

 for(condition)
 {
  //here i'm getting full content of an webpage(huge data) and some regexp to match data

  preg_match(regexp,getContent of an URL,$output);

  fputs($fp,$output);
 }
fclose($fp);
}
这里的想法是创建一个文件并将数据写入$output变量,然后创建第二个文件并将$output写入该文件,依此类推,直到 $arrayitem完成

但我观察到的是,第二个文件和其他 在第一个文件完成之前,将创建连续的文件 并且文件大小增长缓慢刷新时文件大小为 改变 这怎么可能呢? 这里到底发生了什么?
通常只有在完成第一个文件后才能创建下一个文件,对吗