Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Apr 2004 15:19:11 +0200
From:      "Markus Pfister" <>
To:        <>
Subject:   FreeBSD Port: php4-4.3.5: fgetcvs problem with "\n" in delimited data
Message-ID:  <000001c41efe$69f46f90$9101a8c0@gandalf>

Next in thread | Raw E-Mail | Index | Archive | Help
Hi Ale,

If I sent this mail to the wrong (not in charge) person, please
The folks running our webserver run the php4 4.3.5 FreeBSD port from the site.

Consider the following code:

$fn = tempnam( '/tmp', 'testfile' );
if( $fp = fopen( $fn, 'w' ) )
        fwrite( $fp, "\"one\",\"a\nline\nwith\nlinebreaks\n\"" );
        $fp = fopen($fn, "r");
        $row = 1;
        while (($data = fgetcsv($fp, 10000, ",")) !== FALSE)
                $num = count($data);
                echo "<p> $num fields in line $row: <br />\n";
                for ($c=0; $c < $num; $c++)
                        echo nl2br($data[$c]) . "<br />\n";

Problem description:
It seems, that former versions of fgetcsv was able to parse delimited
data fields containing line breaks (\n), where the 4.3.5 version (see for detailed information)
"forgets" that data.

Sample code output:
This code produces on a Linux box with php 4.3.1 or 4.3.5 installed:

Content-type: text/html
X-Powered-By: PHP/4.3.1

<p> 2 fields in line 1: <br />
one<br />
a<br />
line<br />
with<br />
linebreaks<br />
<br />

On a FreeBSD System with php 4.3.5 installed the output is:

<p> 2 fields in line 1: <br />
one<br />
<br />

Could someone try to reproduce the described behaviour and let me know
if my observations are correct or if I simply did something wrong.
Markus Pfister

Want to link to this message? Use this URL: <$69f46f90$9101a8c0>