#49966 [Opn->Bgs]: fputcsv does not respect trailing zeros in number-like strings
ID: 49966
Updated by: jani@php.net
Reported By: shankao at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Filesystem function related
Operating System: Centos 5
PHP Version: 5.3.1RC2
New Comment:
The CSV definition does not require all values to be enclosed in
quoting char. PHP only does so when needed. But it isn't an AI that can
figure out when you might or might not want them to be quoted.
Previous Comments:
------------------------------------------------------------------------
[2009-10-23 09:58:17] shankao at gmail dot com
Description:
------------
You can get into problems with number-like strings.
For example, phones with trailing zeros 056033023 don't get quoted in
the generated csv file. So, a workaround for that could be add an extra
space character before the real value.
Reproduce code:
---------------
---
From manual page: function.fputcsv
---
$csv_data = array();
$csv_data[] = '021323123'; // Includes trailing zeros
fputcsv ($fd, $csv_data);
Expected result:
----------------
Phone field keeps trailing zeros
Actual result:
--------------
Phone field gets zeros removed cause interpreted as integer instead of
string
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49966&edit=1
Thread (2 messages)