On Tue, 2004-07-20 at 21:34, Olga wrote: > > 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 > ---- options.txt *'endofline'* *'eol'* *'noendofline'* *'noeol'* 'endofline' 'eol' boolean (default on) local to buffer {not in Vi} When writing a file and this option is off and the 'binary' option is on, no <EOL> will be written for the last line in the file. This option is automatically set when starting to edit a new file, unless the file does not have an <EOL> for the last line in the file, in which case it is reset. Normally you don't have to set or reset this option. When 'binary' is off the value is not used when writing the file. When 'binary' is on it is used to remember the presence of a <EOL> for the last line in the file, so that when you write the file the situation from the original file can be kept. But you can change it if you want to. :set noendofline or something like that Craig