ID:               44034
 User updated by:  php at commerco dot net
 Reported By:      php at commerco dot net
-Status:           Feedback
+Status:           Open
 Bug Type:         Filesystem function related
 Operating System: MS Win2K
 PHP Version:      6CVS-2008-02-04 (snap)
 New Comment:

Thank you for your post.  Unfortunately, the current build version
(php6.0-win32-200802041530) did not cure the issue.


Previous Comments:
------------------------------------------------------------------------

[2008-02-10 01:27:37] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php6.0-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php6.0-win32-latest.zip



------------------------------------------------------------------------

[2008-02-04 08:40:49] php at commerco dot net

Description:
------------
Using FILE, when the parameter FILE_IGNORE_NEW_LINES is used, if the
file uses a line termination of \n the operation works as expected.

If the file uses a line termination of \r\n (MS Windows), the \r is not
removed.

One might argue that the NEW_LINES is \n alone, and of course FILE
works fine when the file has a \n terminator, however, \r\n is a common
line record (line) terminator on a windows system.  If memory serves,
this kind of issue has been addressed in some other PHP functions, so it
would be great if you would consider addressing this one too.

The problem really becomes apparent if you take two arrays derived from
FILE functions and combine them via an array_combine.

Reproduce code:
---------------
/* create 2 files in notepad.
$somefile1 data:
foo
bar
etc
$somefile2 data:
123
456
789
*/
$a1 = file($somefile1, FILE_IGNORE_NEW_LINES+FILE_TEXT);
$a2 = file($somefile2, FILE_IGNORE_NEW_LINES+FILE_TEXT);
$a3 = array_combine($a1, $a2);
print_r($a3);

Expected result:
----------------
$a3 is an array with three entries with both key and data each entry
having a length of 3 bytes.

Array
(
    [foo] => 123
    [bar] => 456
    [etc] => 789
)

(which is what happens when a file contains \n terminated lines).


Actual result:
--------------
$a3 is an array with three entries with both key and data each entry
having a length of 4 bytes.

Array
(
    [foo
] => 123
    [bar
] => 456
    [etc
] => 789
)

(which is what happens when a file contains \r\n terminated lines).



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44034&edit=1

Reply via email to