Reputation: 3253
i have a for loop that will loop through a set of page in 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";
}
}
the problem is that the result is displayed after the last page is executed, since it will loop through 500 pages which takes more time. so how can i make this code display the print result as it is executed each cycle,
Upvotes: 0
Views: 191
Reputation: 61557
while(something)
{
// do something
echo "Hi";
flush();
}
Using the flush()
function will output everything to the browser that has been sent so far (sent as in echo
, print
or other similar functions.).
Upvotes: 1