#42219 [NEW]: length argument of fgetcsv() is not effective/working in PHP6

From: Date: Mon, 06 Aug 2007 12:01:49 +0000
Subject: #42219 [NEW]: length argument of fgetcsv() is not effective/working in PHP6
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115795@lists.php.net to get a copy of this message
From:             nikhil dot gupta at in dot ibm dot com
Operating system: Linux
PHP version:      6CVS-2007-08-06 (CVS)
PHP Bug Type:     Filesystem function related
Bug description:  length argument of fgetcsv() is not effective/working in PHP6 

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 bug report at http://bugs.php.net/?id=42219&edit=1
-- 
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42219&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42219&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42219&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42219&r=fixedcvs
Fixed in release:             http://bugs.php.net/fix.php?id=42219&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42219&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42219&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42219&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42219&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42219&r=notwrong
Not enough info:              http://bugs.php.net/fix.php?id=42219&r=notenoughinfo
Submitted twice:              http://bugs.php.net/fix.php?id=42219&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42219&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42219&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42219&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42219&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42219&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42219&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42219&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42219&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#115795) next »