> From: james@xxxxxxxxxxxxx > To: ajwei@xxxxxxxxxxxxx > CC: php-windows@xxxxxxxxxxxxx > Date: Mon, 9 Feb 2009 10:34:45 -0500 > Subject: Re: Math Operator Problem? > > On Mon, 2009-02-09 at 07:32 -0500, Alice Wei wrote: > > Hi, > > > > I have a snippet of code as follows: > > > > while (!feof($fh2)) { > > > > $total_time=0; > > $lines= fgets($fh2); > > $count= strlen($lines); > > if ($count == 0) { > > //There are no lines > > } > > else { > > > > $total_time += $lines; > > > > } > > } > > > > What I am trying to do here is to increment the total_time value and > > have it display on the screen without changing the actual input file. > > However, when I tried to output the result on the screen, all I am > > getting is the same value as I have in the text file originally. Can > > anyone on the list please give me some insight on what I am doing > > wrong here? > > Thanks in advance. > > > > > > Alice > > > > Alice, > > It might help if you posted a couple of lines from the $fh2 file. Are > any of the lines in it empty? > Hi, James: I believe this is something like what is in my file: 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? Thanks again. > Thanks, > James > > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Use Messenger to talk to your IM friends, even those on Yahoo! Talk now! _________________________________________________________________ Use Messenger to talk to your IM friends, even those on Yahoo! http://ideas.live.com/programpage.aspx?versionId=7adb59de-a857-45ba-81cc-685ee3e858fe