#42210 [Opn->Bgs]: fputcsv() not consistent to enclose with other than default enclosure value
ID: 42210
Updated by: iliaa@php.net
Reported By: nikhil dot gupta at in dot ibm dot com
-Status: Open
+Status: Bogus
Bug Type: Filesystem function related
Operating System: Linux, Win32-xp
PHP Version: 5CVS-2007-08-05 (CVS)
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
The CSV definition does not require all values to be enclosed in
quoting
char. PHP only does so when needed.
Previous Comments:
------------------------------------------------------------------------
[2007-08-05 12:33:48] nikhil dot gupta at in dot ibm dot com
Description:
------------
fputcsv() is behaving differently with different fields values. A
string provided with a blank space gets enclosed by fputcsv but with
other characters other than space are not enclosed. For details refer to
the reproduce code and expected and actual output.
Reproduce code:
---------------
<?php
$fh = fopen("file.tmp","w");
$field_array = array('abc,def');
$field_array2 = array('abc def');
var_dump( fputcsv($fh, $field_array, '+', '$') );
fclose($fh);
var_dump( file_get_contents("file.tmp") );
unlink("file.tmp");
$fh = fopen("file2.tmp","w");
var_dump( fputcsv($fh, $field_array2, '+', '$') );
fclose($fh);
var_dump( file_get_contents("file2.tmp") );
?>
Expected result:
----------------
int(8)
string(8) "$abc,def$
"
int(10)
string(10) "$abc def$
"
Actual result:
--------------
int(8)
string(8) "abc,def
"
int(10)
string(10) "$abc def$
"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42210&edit=1
Thread (2 messages)