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:36, Olga wrote:
>> > 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
>> >
>>
>> Yes, I agree with you - I can either adjust the code or get back to my
>> original question. :) How do I get an editor to not insert the trailing
>> blank line ( LF line) rather than add it (with such editors as vi and
>> nano)?
> ---
> don't know - I don't use vi/vim
> but I would start with man vi
> and that should lead you to
> /usr/share/doc/vim-common-6.2.457/docs
>
> Craig
>

Yes, thank you... I will look at those. I also found some info about the
php fgets function. It was interesting in itself to see how fgets
interprets line feed.

http://www.guides.sk/php_manual/function.fgets.php




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

  Powered by Linux