From: [EMAIL PROTECTED] Operating system: Windows XP PHP version: 5.2.6 PHP Bug Type: *General Issues Bug description: fputcsv does not add the correct newline character on Windows
Description: ------------ Per the documentation for the fputcsv() function, it adds a newline to the end of the csv string it returns. However, it is hardcoded to be '\n' ( default for unix newline ), while Windows uses \r\n. PHP should do this as well. Below is a patch to fix this issue; it uses the constant PHP_EOL to get the correct newline to use on the current platform: Index: php-src/ext/standard/file.c =================================================================== RCS file: /repository/php-src/ext/standard/file.c,v retrieving revision 1.530 diff -r1.530 file.c 2107c2107 < smart_str_appendc(&csvline, '\n'); --- > smart_str_appendc(&csvline, PHP_EOL); Reproduce code: --------------- $array1 = array("a","b","c"); $array2 = array("d","e","f"); echo fputcsv($array1).fputcsv($array2); Expected result: ---------------- "a","b","c" "d","e","f" Actual result: -------------- "a","b","c""d","e","f" -- Edit bug report at http://bugs.php.net/?id=46367&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46367&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46367&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46367&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=46367&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=46367&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=46367&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=46367&r=needscript Try newer version: http://bugs.php.net/fix.php?id=46367&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=46367&r=support Expected behavior: http://bugs.php.net/fix.php?id=46367&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=46367&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=46367&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=46367&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46367&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=46367&r=dst IIS Stability: http://bugs.php.net/fix.php?id=46367&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=46367&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=46367&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=46367&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=46367&r=mysqlcfg