Reply to Line count/blank line issue with file(), etc.

Your name:

Reply:


Posted by Curtis on 12/27/05 05:26

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:

$lines = file($filename);
echo count($lines);

gives three lines as the count for both:

Line 1
Line 2
Line 3 <--Text stops here

and

Line 1
Line 2
Line 3
<--New line but no text

This shows up as four lines:

Line 1
Line 2
Line 3
<--New line but no text
<--New line but no text

A space in the last blank line makes the count correct.

This behavior is a problem when I files sequentially--if the
file has a blank line at the end, the expected behavior
would seem to me to be:

File A Line 1
File A Line 2
File A Line 3
<--Blank line
File B Line 1
File B Line 2
File B Line 3

Instead, they list as:

File A Line 1
File A Line 2
File A Line 3
File B Line 1
File B Line 2
File B Line 3

Thoughts?

--

Curtis

Visit We the Thinking
www.wethethinking.com
An online magazine/forum
devoted to philosophical
thought.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация