FreeBSD Port: php4-4.3.5: fgetcvs problem with "\n" in delimited data

Markus Pfister pfm at
Sat Apr 10 05:17:49 PDT 2004

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

More information about the freebsd-ports mailing list