php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42219 length argument of fgetcsv() is not effective/working in PHP6
Submitted: 2007-08-06 12:01 UTC Modified: 2008-02-06 02:58 UTC
From: nikhil dot gupta at in dot ibm dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 6CVS-2007-08-06 (CVS) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nikhil dot gupta at in dot ibm dot com
New email:
PHP Version: OS:

 

 [2007-08-06 12:01 UTC] 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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-06 02:58 UTC] felipe@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 11:01:37 2024 UTC