#46463 [NEW]: fgetcsv() omits empty fields

From: Date: Sun, 02 Nov 2008 09:26:58 +0000
Subject: #46463 [NEW]: fgetcsv() omits empty fields
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-130454@lists.php.net to get a copy of this message
From: php-bugs at christoph-jeschke dot de Operating system: GNU/Linux PHP version: 5.2.6 PHP Bug Type: Filesystem function related Bug description: fgetcsv() omits empty fields Description: ------------ Since PHP5, fgetcsv() omits empty fields instead returning a empty string as did in PHP4. Reproduce code: --------------- csv.php ======= <?php $h = fopen('paragraph.csv','r'); while(false !== ($l = fgetcsv($h, 1024, '§', '\\'))) { var_dump($l); } fclose($h); ?> paragraph.csv ============= line1f1§line1f2§line1f3 line2f1§line2f2§line2f3 line3f1§§line3f3 Expected result: ---------------- array(3) { [0]=> string(7) "line1f1" [1]=> string(7) "line1f2" [2]=> string(7) "line1f3" } array(3) { [0]=> string(7) "line2f1" [1]=> string(7) "line2f2" [2]=> string(7) "line2f3" } array(3) { [0]=> string(7) "line3f1" [1]=> string(0) "" [2]=> string(7) "line3f3" } Actual result: -------------- array(3) { [0]=> string(7) "line1f1" [1]=> string(7) "line1f2" [2]=> string(7) "line1f3" } array(3) { [0]=> string(7) "line2f1" [1]=> string(7) "line2f2" [2]=> string(7) "line2f3" } array(2) { [0]=> string(7) "line3f1" [1]=> string(7) "line3f3" } -- Edit bug report at http://bugs.php.net/?id=46463&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46463&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46463&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46463&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=46463&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=46463&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=46463&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=46463&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=46463&r=needscript Try newer version: http://bugs.php.net/fix.php?id=46463&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=46463&r=support Expected behavior: http://bugs.php.net/fix.php?id=46463&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=46463&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=46463&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=46463&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46463&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=46463&r=dst IIS Stability: http://bugs.php.net/fix.php?id=46463&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=46463&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=46463&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=46463&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=46463&r=mysqlcfg

« previous php.bugs (#130454) next »