|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21556 fgetcsv hangs if the csv file contains a "
Submitted: 2003-01-09 16:01 UTC Modified: 2003-01-31 13:47 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: caseymanus at msn dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.3.0 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
38 + 42 = ?
Subscribe to this entry?

 [2003-01-09 16:01 UTC] caseymanus at msn dot com
Usings the basic fgetcsv example, 

$row = 1;
$fp = fopen ("test.csv","r");
while ($data = fgetcsv ($fp, 1000, ",")) {
    $num = count ($data);
    print "<p> $num fields in line $row: <br>\n";
    for ($c=0; $c < $num; $c++) {
        print $data[$c] . "<br>\n";
fclose ($fp);
If the CSV contains a double quote, fgetcsv hangs on that line and memory utilization spikes.  I have reproduced this.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-09 16:24 UTC]
Could you please provide a sample csv file that could be used to replicate the problem.
 [2003-01-09 16:32 UTC] caseymanus at msn dot com

Just copy this text to a file and then save it as test.csv

just a bunch of data, jere, fadjsfd, aksjfllsd, adfjsdkl
fajsdlfls, afdlsfkjfdsal, adjfsljfas, adfjsldkfjs, dkslafj
fjadskjf, aksdjfls, afksfdjl""", jlkjl, jlkjkl, jlkjl, jlak
fajlsd, jfadlsl, ajfldsja, akfjsdl, ajsdflj, ajdskfks
as you will see it hangs on the third line
 [2003-01-09 17:10 UTC]
I've just commited a patch to the CVS that may resolve the problem, please wait a few hours and then grab a snapshot from
 [2003-01-31 13:47 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Jan 26 22:05:54 2023 UTC