#48175 [Opn]: FILE_IGNORE_NEW_LINES don't remove "\r\n"

From: Date: Thu, 07 May 2009 12:42:05 +0000
Subject: #48175 [Opn]: FILE_IGNORE_NEW_LINES don't remove "\r\n"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-136926@lists.php.net to get a copy of this message
ID: 48175 Updated by: jani@php.net Reported By: carsten_sttgt at gmx dot de Status: Open Bug Type: Filesystem function related Operating System: * PHP Version: 5.2.9 New Comment: See also bug #44034 Previous Comments: ------------------------------------------------------------------------ [2009-05-07 09:23:02] carsten_sttgt at gmx dot de Description: ------------ Hello, if I use FILE_IGNORE_NEW_LINES with file(), a "\r\n" will not be removed. It works with a single "\r" or "\n". (Tested on *nix and Windows.) Regards, Carsten Reproduce code: --------------- <?php ini_set('auto_detect_line_endings', '1'); $f = tempnam('', 'php'); file_put_contents($f, "one\ntwo\n"); $a = file($f, FILE_IGNORE_NEW_LINES); echo ord($a[0][strlen($a[0]) - 1]).PHP_EOL; file_put_contents($f, "one\rtwo\r"); $a = file($f, FILE_IGNORE_NEW_LINES); echo ord($a[0][strlen($a[0]) - 1]).PHP_EOL; file_put_contents($f, "one\r\ntwo\r\n"); $a = file($f, FILE_IGNORE_NEW_LINES); echo ord($a[0][strlen($a[0]) - 1]).PHP_EOL; unlink($f); ?> Expected result: ---------------- 101 101 101 Actual result: -------------- 101 101 13 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48175&edit=1

« previous php.bugs (#136926) next »