|
Posted by Curtis on 12/28/05 01:25
J.O. Aho <user@example.net> wrote in message
news:41cjckF1bhrihU1@individual.net...
> Curtis wrote:
> > When reading in text files, if the file has a blank line
> > following text, but no text, it is apparently being
ignored
> > on a file() call:
>
> No, this ain't a file() issue but the way HTML works.
>
> change this
> > $lines = file($filename);
> > echo count($lines);
>
> to
>
> ?>
> <pre>
> <?PHP
> $lines = file($filename);
> echo count($lines);
> ?>
> </pre>
> <?PHP
That should not make any difference, J.O. Please not that
I'm only displaying the COUNT of the lines, not the lines
themselves.
The point was that file() seems to be eating THE LAST
appended newline--it does not show up in the count.
In fact, in my code I'm converting all forms/combinations of
newline to \r, processing the stuff, then converting any \r
that's left over at the end to \n<br /> tags, to display
properly as both HTML source and viewed HTML.
> > A space in the last blank line makes the count correct.
>
> HTML don't respect linebreaks, you need to change those to
<br> nl2br(9 can do
> that for your. Another way is to make the output between
<pre></pre>.
Sorry I didn't make myself clear. I'm not simply dumping
this to an HTML file. I'm processing the text, and any
newline will eventually be displayed as a break tag--but
first my code has to SEE the newline, and it seems to
flat-out be missing with file().
I experimented with fgets() this morning, and the line count
seems correct for that function.
--
Curtis
Visit We the Thinking
www.wethethinking.com
An online magazine/forum
devoted to philosophical
thought.
Navigation:
[Reply to this message]
|