#26600 [Opn->Bgs]: only one line CSV
| From: | iliaa@php.net | Date: | Fri, 12 Dec 2003 14:30:01 +0000 |
| Subject: | #26600 [Opn->Bgs]: only one line CSV | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-51988@lists.php.net to get a copy of this message | ||
ID: 26600
Updated by: iliaa@php.net
Reported By: dozoyousan at mail dot goo dot ne dot jp
-Status: Open
+Status: Bogus
Bug Type: Unknown/Other Function
Operating System: Win2k,Linux
PHP Version: 4.3.4
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
You need to use filesize() + 1 because the last byte is reserved for
(\0).
Previous Comments:
------------------------------------------------------------------------
[2003-12-12 05:56:32] dozoyousan at mail dot goo dot ne dot jp
Description:
------------
If only one line csv file , fgetcsv read two or more lines.
Reproduce code:
---------------
<?
$file_name = "temp.csv";
$file_ptr = fopen($file_name, "w");
fwrite( $file_ptr, "php, pear, pecl");
fclose( $file_ptr );
$file_ptr = fopen( $file_name, "r" );
while( $rows = fgetcsv( $file_ptr , filesize( $file_name ), "," ) )
echo nl2br( print_r( $rows, true ));
fclose( $file_ptr );
?>
Expected result:
----------------
Array
(
[0] => php
[1] => pear
[2] => pecl
)
Actual result:
--------------
Array
(
[0] => php
[1] => pear
[2] => pec
)
Array
(
[0] => l
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26600&edit=1