|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-02-06 02:58 UTC] felipe@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Jan 07 06:00:01 2026 UTC |
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)