trailing blank line in a text file

Olga olga at urbantimes.net
Wed Jul 21 03:36:35 UTC 2004


> 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)?





More information about the users mailing list