|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2008-11-06 13:49 UTC] jmertic@php.net
  [2009-07-17 11:41 UTC] chris dot tatedavies at inflightproductions dot com
  [2010-03-10 19:50 UTC] m_rayman at bigfoot dot com
  [2010-03-10 20:41 UTC] johannes@php.net
 
-Package: Feature/Change Request
+Package: *General Issues
  [2010-03-10 20:41 UTC] johannes@php.net
  [2012-09-19 10:22 UTC] gtisza at gmail dot com
  [2020-03-30 16:58 UTC] cmb@php.net
 
-Status:      Open
+Status:      Duplicate
-Assigned To:
+Assigned To: cmb
  [2020-03-30 16:58 UTC] cmb@php.net
 | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 11:00:01 2025 UTC | 
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"