2010-02-24 104 views
0

我有一个循环,将通过一组页面在php中循环。在php中显示结果?

 for ($count=0;$count<=$curr;$count=$count + 10) 
     { 

      if ($find==1) { 

       $result = "file.php?count=$count"; 
       }else { 
       $result = "file2.php?count=$count"; 

     } 

    $match = file_get_contents($result); 
    $nc=$count+10; 


if (preg_match("/\b$file\b/i", $match)) { 
    print "found in $count"; 

} else { 
    print "not found in $count"; 
} 

} 

问题是结果显示在最后一页执行后,因为它会循环500页,这会花费更多时间。那么,如何使这个代码显示的打印结果,因为它执行的每个周期,

回答

1
while(something) 
{ 
    // do something 
    echo "Hi"; 
    flush(); 

} 

使用flush()功能将输出一切已到目前为止已发送的浏览器(发送在echoprint或其他类似的功能)。

+0

使用flush()函数将输出到目前为止已发送的浏览器的所有内容。送到哪里? – Sarfraz 2010-02-24 18:34:18

+0

已更新:'(通过回显,打印或其他类似函数发送)' – 2010-02-24 18:35:31

+0

通过使用其他输出缓冲区函数(例如,可以清除输出缓冲区而不是发送它),可以更好地控制此行为。看到'flush()'的手册页上的边栏:http://php.net/flush – Dolph 2010-02-24 18:41:53