|  | Posted by Curtis on 12/27/05 05:26 
When reading in text files, if the file has a blank linefollowing 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.
  Navigation: [Reply to this message] |