elitegosu Posted March 29, 2009 Share Posted March 29, 2009 Hi, I have a really newbie question. How do I print my text within a delay inside the loop? For example: for ($i=0;$i<=10;$i++) { echo "this is line: ".$i."<br />"; } I want to print one line and then have a one second delay and then print the next one and so on....I tried sleep(1) function after print line within the loop, but it waits 10 seconds instead (going through the whole loop) and only then printing everything at once. How do I make it print one line at a time with a one second delay in between? Link to comment https://forums.phpfreaks.com/topic/151656-print-php-lines-with-delay-in-between/ Share on other sites More sharing options...
killah Posted March 29, 2009 Share Posted March 29, 2009 for($i = 1; $i <= 10; ++$i) { echo 'This is line '.$i.'<br />'; ob_flush(); flush(); sleep(1); } Link to comment https://forums.phpfreaks.com/topic/151656-print-php-lines-with-delay-in-between/#findComment-796430 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.