--- updated with Sleep() --- function TestFunc(){ $cnt = array(1,2,3,4,5,6,7,8,9,10); $i=0;
while($i <=count($cnt)){ //sleep(1); set_time_limit(2); //sleep(1); echo $cnt[$i].str_repeat(" ", 300) . "<br />";; sleep(1); ob_flush(); flush(); //sleep(1); $i++; } --- End --- Wherever I put sleep(1), notice the comments, in the func all it dose is wait 10 seconds then shows the full output and not each result 1 at a time to the screen. Any further guidance is very much appreciated. Dave C -----Original Message----- From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED] Sent: 29 January 2004 13:12 To: 'Dave Carrera'; [EMAIL PROTECTED] Subject: RE: [PHP] Show Results one at a time ? On 29 January 2004 12:51, Dave Carrera wrote: > Hi List, > > I have a test function who's aim is to take an array an do something > which each value of the array and show the result on screen one at a > time. > > --- Test Function Code --- > > function TestFunc(){ > $cnt = array(1,2,3,4,5,6,7,8,9,10); > $i=0; > > while($i <=count($cnt)){ > set_time_limit(2); > echo $cnt[$i].str_repeat(" ", 300) . "<br />";; > ob_flush(); > flush(); > $i++; > } > > --- End --- Your understanding of ob_flush() and flush() looks right. However, at the moment you've got nothing in there to insert a delay between the echos, so it'll all just be whizzing out at top speed. Try inserting a sleep(1) into the body of the loop, to wait for 1 second on each iteration. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.572 / Virus Database: 362 - Release Date: 27/01/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.572 / Virus Database: 362 - Release Date: 27/01/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php