Date: Sat, 10 Apr 2004 15:19:11 +0200 From: "Markus Pfister" <pfm@bluewin.ch> To: <ale@FreeBSD.org> Cc: ports@FreeBSD.org 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 apologize. The folks running our webserver run the php4 4.3.5 FreeBSD port from the http://www.freshports.org/lang/php4 site. Consider the following code: <?php $fn = tempnam( '/tmp', 'testfile' ); if( $fp = fopen( $fn, 'w' ) ) { fwrite( $fp, "\"one\",\"a\nline\nwith\nlinebreaks\n\"" ); fclose($fp); $fp = fopen($fn, "r"); $row = 1; while (($data = fgetcsv($fp, 10000, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br />\n"; $row++; for ($c=0; $c < $num; $c++) { echo nl2br($data[$c]) . "<br />\n"; } } fclose($fp); } ?> 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 http://www.kim-dojo.ch/php/kisgb/ck98.php 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. Regards Markus Pfister Visit http://www.kim-dojo.ch
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000001c41efe$69f46f90$9101a8c0>