Hi all,
I am running a script that processes files line by line.
It takes a while so I would like to echo a status update with each line so we can see where we are in the process.
I started reading on the output buffers but that doesn't do what I want.
My code (with the essential lines here) is:

<?php

ob_start();
echo 'Start the process';
ob_flush();

// here I open a file and read it into an array, left out to keep it simple.

foreach ($uniqlist as $regel)
{
echo 'we are on line ' . $regel .' <br>';
ob_flush();
}
echo 'Finished';
ob_end_flush();

?>

Any ideas of why the output buffering is not doing what I expected?

Hi Chrishea,
Thanks for pointing me to the documentation. Now I have tried the example:

<?php
ob_start();
for($i=0;$i<70;$i++)
{
echo 'printing...<br />';
ob_flush();
flush();
usleep(300000);
}
?>

I have placed this in a file, on my site, and when I call it it still just waits until the entire for-loop is finished and then dumps the entire output to my browser. I had expected it to print it line by line.
So I am doing something wrong here?
Rob

Member Avatar for P0lT10n

if i'm right, you must do:

echo "we are online".$regel['your_tag']."<br />";

Hi P0IT10n,
So you are suggesting that I use double quotes in stead of single quotes?
I have tried the sample from the manual with double quotes, but that doesn't matter either.
It sill runs through the entire for and then dumps it to my browser, the test that I had described in my post that is also in the manual is on-lien here: http://www.gpsopleiding.nl/test.php
You can see that it doesn't print line by line.
And that is what I want
Rob

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.