|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-02-10 06:57 UTC] php at commerco dot net
[2010-06-21 00:29 UTC] felipe@php.net
-Status: Open
+Status: Wont fix
[2010-06-21 00:29 UTC] felipe@php.net
[2021-04-20 12:13 UTC] php at yopmail dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 18:00:02 2025 UTC |
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).