#42219 [Opn->Csd]: length argument of fgetcsv() is not effective/working in PHP6
| From: | felipe@php.net | Date: | Wed, 06 Feb 2008 02:58:26 +0000 |
| Subject: | #42219 [Opn->Csd]: length argument of fgetcsv() is not effective/working in PHP6 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-122021@lists.php.net to get a copy of this message | ||
ID: 42219
Updated by: felipe@php.net
Reported By: nikhil dot gupta at in dot ibm dot com
-Status: Open
+Status: Closed
Bug Type: Filesystem function related
Operating System: Linux
PHP Version: 6CVS-2007-08-06 (CVS)
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2007-08-06 12:01:48] nikhil dot gupta at in dot ibm dot com
Description:
------------
while using length argument value less than the line size to be read,
fgetcsv() outputs result without considering the length value that is
passed and assumes the maximum length always. This behaviour is correct
in PHP5.
Reproduce code:
---------------
<?php
$csv_string = 'water,fruit';
$filename = "file.tmp";
$file_handle = fopen($filename, "w");
fwrite($file_handle, $csv_string );
fclose($file_handle);
$file_handle = fopen($filename, "r");
// use length as less than the actual size of the line
fseek($file_handle, 0, SEEK_SET);
var_dump( fgetcsv($file_handle, 9) );
// read rest of the line
var_dump( fgetcsv($file_handle, 1024) );
// close the file
fclose($file_handle);
//delete file
unlink($filename);
?>
Expected result:
----------------
array(2) {
[0]=>
string(5) "water"
[1]=>
string(3) "fru"
}
array(1) {
[0]=>
string(2) "it"
}
Actual result:
--------------
array(2) {
[0]=>
string(5) "water"
[1]=>
string(5) "fruit"
}
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42219&edit=1