I'm trying to display some content in real time to my visitors using a loop. Problem is that the content is added to the output instead of being replaced with the new one. Here's an example of code which counts from 10 to 0. The output shows the whole set of results instead of counting backwards. I mean, I don't want to see all numbers shown just each number as the counter goes.
ob_end_flush ();
//start buffering
ob_start ();
echo str_pad ( '', 1024 ); // minimum start for Safari
for ( $i = 10; $i > 0; $i --) {
echo str_pad ( "$i<br>
", 8 );
ob_flush ();
flush ();
sleep ( 1 );
}
die ();