From: carsten_sttgt at gmx dot de
Operating system: Irrelevant
PHP version: 5.2.9
PHP Bug Type: Filesystem function related
Bug description: FILE_IGNORE_NEW_LINES don't remove "\r\n"
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 bug report at http://bugs.php.net/?id=48175&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48175&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48175&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48175&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48175&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=48175&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48175&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=48175&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=48175&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=48175&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=48175&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=48175&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=48175&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=48175&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48175&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48175&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48175&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=48175&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=48175&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=48175&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=48175&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=48175&r=mysqlcfg