Bug #69800 [NoF->Nab]: fgetcsv ignores empty trailing field with tab delimiter

From: Date: Sun, 21 Jun 2015 13:39:11 +0000
Subject: Bug #69800 [NoF->Nab]: fgetcsv ignores empty trailing field with tab delimiter
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193738@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69800&edit=1 ID: 69800 Updated by: cmb@php.net Reported by: richard at roguewavelimited dot com Summary: fgetcsv ignores empty trailing field with tab delimiter -Status: No Feedback +Status: Not a bug Type: Bug Package: *General Issues Operating System: Mac OS X PHP Version: 5.5.25 Assigned To: cmb Block user comment: N Private report: N New Comment: Thanks for the feedback. :) Previous Comments: ------------------------------------------------------------------------ [2015-06-21 13:28:58] richard at roguewavelimited dot com The issue was reported in error. Apparently this action was due to the editor that I was using to edit the data file which changed any trailing tabs to spaces. ------------------------------------------------------------------------ [2015-06-21 04:22:19] php-bugs at lists dot php dot net No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. ------------------------------------------------------------------------ [2015-06-11 18:30:15] cmb@php.net I can't reproduce the described behavior: <http://3v4l.org/c2coK>. Please run this script on your system, and report the results. ------------------------------------------------------------------------ [2015-06-11 14:09:01] richard at roguewavelimited dot com Description: ------------ Using a tab delimiter with fgetcsv, if the last field of a row is empty, then that field is not included in the returned fields. (Actually in my tests, there can be any number of tabs following the last non-empty data field and all will be ignored.) For example: Correct: 1<tab>2<tab>3 returns array("1","2","3") Wrong: 1<tab>2<tab> returns array("1","2") should be returned as array("1","2","") If you perform this same test using commas as delimiters it works as expected. Test script: --------------- Paste this into a new file (be sure to include the trailing tab): T17492-RB "Delta Faucets" Change the data file name and run this script. The echo should show 3 but shows 2 $fh = fopen('the_data_file','r'); $fields = fgetcsv($fh, 999999, "\t", '"', "\\"); echo (count($fields)); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69800&edit=1

« previous php.bugs (#193738) next »