From: Operating system: freebsd PHP version: 5.2.17 Package: Streams related Bug Type: Bug Bug description:fgetcsv parsing error
Description: ------------ I save csv file from MS Office excel. The file looks as below. A,B,C,D AAA,"BB,B","CCC,'\C,,CCC","D,DDD" "AA""AA","BB"",BBB""B","CC\""CC,,C""",DDD fgetcsv seems to be incorrect, if the cell in EXCEL include escape string. Test script: --------------- $fp = fopen('test3.csv', 'r'); while ($arr = fgetcsv($fp, 10000, ',', '"')) { print_r($arr); } Expected result: ---------------- Array ( [0] => A [1] => B [2] => C [3] => D ) Array ( [0] => AAA [1] => BB,B [2] => CCC,'\C,,CCC [3] => D,DDD ) Array ( [0] => AA"AA [1] => BB",BBB"B [2] => CC\"CC,,C" [3] => DDD ) Actual result: -------------- Array ( [0] => A [1] => B [2] => C [3] => D ) Array ( [0] => AAA [1] => BB,B [2] => CCC,'\C,,CCC [3] => D,DDD ) Array ( [0] => AA"AA [1] => BB",BBB"B [2] => CC\"CC [3] => [4] => C""" [5] => DDD ) -- Edit bug report at http://bugs.php.net/bug.php?id=53822&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53822&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53822&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53822&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53822&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53822&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53822&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53822&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53822&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53822&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53822&r=support Expected behavior: http://bugs.php.net/fix.php?id=53822&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53822&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53822&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53822&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53822&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53822&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53822&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53822&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53822&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53822&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53822&r=mysqlcfg