# Bug #27730 (fgetcsv() fails on 2 newlines)

- Thread: https://externals.io/message/8887
- Original archive: https://news-web.php.net/php.internals/8887
- Started by Moriyoshi Koizumi on 2004-04-02T08:24:15+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #8887 — Moriyoshi Koizumi — 2004-04-02T08:24:15+00:00

URL: https://externals.io/message/8887#8887

Hi,

As this bug was already marked as a documentation problem and
handled by Rasmus, but I don't think this is a problem of
that kind, because versions prior to 4.3.5 returns an array
that contains a null string element and the script supplied
by the user on bug #27730 had worked flawlessly.

I think this should also be addressed during the RC period
of 4.3.6.

Regards,
Moriyoshi

---

## #8888 — Moriyoshi Koizumi — 2004-04-02T08:33:35+00:00

URL: https://externals.io/message/8887#8888 · In reply to: #8887

> that kind, because versions prior to 4.3.5 returns an array
> that contains a null string element and the script supplied
> by the user on bug #27730 had worked flawlessly.

Here I mean: because in versions prior to 4.3.5 `fgetcsv()`
returns an array that contains a null string element for an
empty line..

Anyway, I might be a bit too late.

Moriyoshi

---

## #8893 — Ilia Alshanetsky — 2004-04-02T14:17:42+00:00

URL: https://externals.io/message/8887#8893 · In reply to: #8887

I've just tried the script an both PHP 4.3.6, 4.2.3 and 5.0 return the same 
results.

<?php
        $fp = fopen("test.csv", 'w' );
        fwrite( $fp, "one;val1\ntwo;val2\n\nthree;val3\n" );
        fclose( $fp );

        $fp = fopen("test.csv", 'r' );
        $items = array( );
        while( $d = fgetcsv( $fp, 4096, ';' ) ) {
                var_dump($d);
        }
        fclose( $fp );
?>

Result:

array(2) {
  [0]=>
  string(3) "one"
  [1]=>
  string(4) "val1"
}
array(2) {
  [0]=>
  string(3) "two"
  [1]=>
  string(4) "val2"
}
array(1) {
  [0]=>
  string(0) ""
}
array(2) {
  [0]=>
  string(5) "three"
  [1]=>
  string(4) "val3"
}

Ilia

---

## #8897 — Rasmus Lerdorf — 2004-04-02T15:40:02+00:00

URL: https://externals.io/message/8887#8897 · In reply to: #8887

Uh, huh?  The behaviour in 4.3.5 is the same as always.  Nothing has
changed here.  It was simple user error in that report.

-Rasmus



> Hi,
>
> As this bug was already marked as a documentation problem and
> handled by Rasmus, but I don't think this is a problem of
> that kind, because versions prior to 4.3.5 returns an array
> that contains a null string element and the script supplied
> by the user on bug #27730 had worked flawlessly.
>
> I think this should also be addressed during the RC period
> of 4.3.6.
>
> Regards,
> Moriyoshi
