php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28347 fgetcsv gives error with delim and enclosure set as variable
Submitted: 2004-05-10 10:48 UTC Modified: 2004-06-23 22:53 UTC
From: andrew at shh dot fi Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.0.0RC2 OS: win32
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: andrew at shh dot fi
New email:
PHP Version: OS:

 

 [2004-05-10 10:48 UTC] andrew at shh dot fi
Description:
------------
Pass a variable to the delimiter and enclosure of the fgetcsv returns the error:

Warning: fgetcsv() [function.fgetcsv]: enclosure must be a character in ....

It seems that it will only accept it hard coded:
fgetcsv($handle, 2000, ",", '')
All a bit wierd!

Used the latest CVS

Works in 4.3.7


Reproduce code:
---------------
function csv_import($file, $delimiter = ",", $enclosure='') {
$handle = fopen($file, "r");
	$csv_arr = array();
	 while (($data_arr = fgetcsv($handle, 2000, $delimiter, $enclosure)) !== FALSE) {
		$csv_arr[] = $data_arr;
		$row++;
	 }
	 fclose($handle);
 }

Expected result:
----------------
No error


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-23 22:53 UTC] moriyoshi@php.net
With older releases, your code ends up with the same warning as with PHP 5. The behaviour seems somewhat changed in the recent releases of PHP 4. Not a bug.

 [2004-06-23 22:53 UTC] moriyoshi@php.net
Let me mark this bogus.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 22:01:36 2025 UTC