On Mon, 2009-02-09 at 11:26 -0500, Alice Wei wrote:
<snip>
> > > while (!feof($fh2)) {
> > > 
> > > $total_time=0;
> > > $lines= fgets($fh2);
> > > $count= strlen($lines);
> > > if ($count == 0) {
> > > //There are no lines
> > > }
> > > else {
> > > 
> > > $total_time += $lines;
> > > 
> > > }
> > > }
<snip> 
> 3
> 4
> 2
>  
> Note that there is an extra line break after the last line, but I am not sure 
> if that was what caused the problem. My code above intentionally made the 
> calculation leave out the last line. Or, is it not what it was doing?
>  

Alice,

  I reread your post and think I understand now what you are trying to
do. Every time the while() loop runs (for each line in $fh2) the
$total_time variable gets set to '0'. When the if/else loop runs 0 gets
added to $lines and the result will always be the value of $lines.

  If you want the $total_time to increment with each line in the $fh2
file then you need to declare it outside the while() loop instead of
inside the loop.

Cheers,
James



-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to