RE: [PHP] Show Results one at a time ?
| From: | Ford, Mike [LSS] | Date: | Thu, 29 Jan 2004 13:11:57 +0000 |
| Subject: | RE: [PHP] Show Results one at a time ? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-176191@lists.php.net to get a copy of this message | ||
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: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211