ID:               46463
 User updated by:  php-bugs at christoph-jeschke dot de
 Reported By:      php-bugs at christoph-jeschke dot de
-Status:           Feedback
+Status:           Open
 Bug Type:         Filesystem function related
 Operating System: GNU/Linux
 PHP Version:      5.2.6
 New Comment:

# php -v
PHP 5.2.7RC3-dev (cli) (built: Nov  2 2008 14:49:46)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologie

Returns:

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"
}

The empty field is still omitted.


Previous Comments:
------------------------------------------------------------------------

[2008-11-02 13:40:51] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/



------------------------------------------------------------------------

[2008-11-02 09:26:57] php-bugs at christoph-jeschke dot de

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 this bug report at http://bugs.php.net/?id=46463&edit=1

Reply via email to