tags:

views:

38

answers:

1

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,

+1  A: 
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.).

Chacha102
Using the flush() function will output everything to the browser that has been sent so far. sent where?
Sarfraz
Updated: `(sent as in echo, print or other similar functions)`
Chacha102
You can have more control over this behavior by using the other output buffer functions (for example, you can clear the output buffer instead of ever sending it). See the sidebar on the man page for `flush()`: http://php.net/flush
Dolph
@LiveEn: just in case your loop prints in an HTML table, remember that tables are rendered by browser only when completly received, so even using flush() you won't see anything on browser until you received all data.
Marco Demajo
so what do i need to do if i want to display the details inside a table??
LiveEn
@LiveEn: unfortunately, I don't think you can, it's the way most browsers work.
Marco Demajo