Re: trailing blank line in a text file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2004-07-20 at 20:11, Olga wrote:
> > ----
> > Actually, php doesn't do that, the code in your php program does that
> > and thus, you can adjust the code to do what you want.
> >
> > Craig
> >
> >
> 
> You are right, it's the php code. But I don't see anything wrong with the
> following:
> 
> $x=0;
> $ar=array();
> $f = fopen ("../employee.txt", "r");
> while (!feof ($f)) {
>     $ar[$x] = fgets($f, 4096);
>     $x++;
> }
> 
> The count of $ar returns 4 even though there are actually 3 records. So I
> am not sure if you would call it an expected behaviour.
----
I've not programmed in php in a very long time and my proficiency is
nada. But it would seem to me that all you need is an if statement to
check whether $f is an empty string ("") and then exit the while
statement OR however you are creating employee.txt, to get it to omit
the last LF instead of adding it.

Craig



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux