ID:               44979
 User updated by:  great_boba at yahoo dot com
 Reported By:      great_boba at yahoo dot com
 Status:           Bogus
 Bug Type:         Filesystem function related
 Operating System: Suse
 PHP Version:      5.2.6
 New Comment:

Hello Felipe!

I have kmail address book. I convert it in csv-format where I have some
field containing data like this Vladimir "Great" Struchkov. Kmail
converter save this data in csv-file as "Vladimir "Great" Struchkov"

In my dump all fields are in quotes. But if some fields (not all) are
in quotes I think that we can have some rules to parse this file.
1) If field is in quotes we must have comma after last qoute
2) etc


Previous Comments:
------------------------------------------------------------------------

[2008-05-13 13:02:06] [EMAIL PROTECTED]

This is expected. The "" is an escaped enclosure.

Using:
"A","B","C"
"A","B ""","C """

Array
(
    [0] => A
    [1] => B "
    [2] => C "
)

Use a proper format file.

------------------------------------------------------------------------

[2008-05-13 10:32:21] great_boba at yahoo dot com

Description:
------------
I try to write some application which parse csv-dump. 
Below I write little example to show strange things.

Reproduce code:
---------------
1.csv
"A","B","C"
"A","B "","C """
1.php
<?php

$fp=fopen('1.csv',r');
while($data=fgetcsv($fp,4096,','))
   print_r($data);

fclose($fp);

?>

Expected result:
----------------
Array
{
  [0]=>A
  [1]=>B
  [2]=>C
}
Array
{
  [0]=>A
  [1]=>B "
  [2]=>C ""
}

Actual result:
--------------
Array
{
  [0]=>A
  [1]=>B
  [2]=>C
}
Array
{
  [0]=>A
  [1]=>B ",C """
}


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44979&edit=1

Reply via email to