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

From: Date: Sun, 21 Jun 2015 04:22:20 +0000
Subject: Bug #69800 [Fbk->NoF]: fgetcsv ignores empty trailing field with tab delimiter
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193732@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: php-bugs@lists.php.net Reported by: richard at roguewavelimited dot com Summary: fgetcsv ignores empty trailing field with tab delimiter -Status: Feedback +Status: No Feedback Type: Bug Package: *General Issues Operating System: Mac OS X PHP Version: 5.5.25 Assigned To: cmb Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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 (#193732) next »