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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 20:01:29 2024 UTC