php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26634 fgetcsv error: tab delimited with backslash
Submitted: 2003-12-15 12:58 UTC Modified: 2003-12-15 13:50 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: tgallagher at kalos-inc dot com Assigned: iliaa (profile)
Status: Closed Package: Filesystem function related
PHP Version: 4.3.4 OS: Windows 2000 Pro
Private report: No CVE-ID: None
 [2003-12-15 12:58 UTC] tgallagher at kalos-inc dot com
Description:
------------
Using this sample.txt file with fgetcsv (tab delimited)

" "	""	"971221"	"1"
" "	""	"950707"	"\\
\\"
" "	""	"999637"	"ERYC 250"

on the middle record I get instead of 3 records, I get 7.
instead of 3 records I get 2.
record 1 is read correctly, records 2 and 3 run together.

if I put a space at the beginning of the line with the double back slash it works.

after searching the bug database I believe this error has not been reported.
please correct me if this is not a bug.

Reproduce code:
---------------
<?PHP

$fileHandle = fopen("sample.txt", "r");
while ($data = @fgetcsv ($fileHandle, 5000, "\t"))
{
    print_r($data);
}

?>

Expected result:
----------------
Array
(
    [0] =>  
    [1] => 
    [2] => 971221
    [3] => 1
)
Array
(
    [0] =>  
    [1] => 
    [2] => 950707
    [3] => \\

\\"
Array
(
    [0] => 
    [1] => 
    [2] => 999637
    [3] => ERYC 250
)

Actual result:
--------------
Array
(
    [0] =>  
    [1] => 
    [2] => 971221
    [3] => 1
)
Array
(
    [0] =>  
    [1] => 
    [2] => 950707
    [3] => \\
\\"


    [4] => 
    [5] => 999637
    [6] => ERYC 250
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-15 12:59 UTC] tgallagher at kalos-inc dot com
clairification:
 on the middle record I get 7 fields: expected 3.
 [2003-12-15 13:50 UTC] iliaa@php.net
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 http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

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


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 19:01:29 2024 UTC