#34824 [Opn->Bgs]: Error in fgetcsv parsing with backslashes

From: Date: Tue, 11 Oct 2005 12:17:39 +0000
Subject: #34824 [Opn->Bgs]: Error in fgetcsv parsing with backslashes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-86392@lists.php.net to get a copy of this message
ID: 34824 Updated by: tony2001@php.net Reported By: decryptus at gmail dot com -Status: Open +Status: Bogus Bug Type: Filesystem function related Operating System: Linux debian PHP Version: 4.4.0 New Comment: The CSV file should contain foo|"foo_1\|foo_2" if you want it to be parsed correctly. Try with Excel/Spreadsheet and you'll get the same result. No bug here. Previous Comments: ------------------------------------------------------------------------ [2005-10-11 10:02:09] decryptus at gmail dot com Description: ------------ The function fgetcsv has a problem when I parse a csv file. If you parse a csv for example with delimeter pipe ("|") and you backslashes a pipe, the function shouldn't take it that a delimeter. Reproduce code: --------------- csv_file.csv content: foo|foo_1\|foo_2 ---------------------------------- fgetcsv.php content: <?php $handle = fopen('csv_file.csv','r'); while(($line = fgetcsv($handle,1000,'|')) !== false) { print '<pre>'; print_r($line); print '</pre>'; } ?> Expected result: ---------------- Array ( [0] => foo [1] => foo_1|foo_2 ) Actual result: -------------- Array ( [0] => foo [1] => foo_1\ [2] => foo_2 ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34824&edit=1

« previous php.bugs (#86392) next »