#45596 [NEW]: Dan Brown said this is documentation 'bug' not a user note to fgetcsv function
| From: | gdpurdy at yahoo dot com | Date: | Tue, 22 Jul 2008 17:39:42 +0000 |
| Subject: | #45596 [NEW]: Dan Brown said this is documentation 'bug' not a user note to fgetcsv function | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-991@lists.php.net to get a copy of this message | ||
From: gdpurdy at yahoo dot com
Operating system:
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: Dan Brown said this is documentation 'bug' not a user note to fgetcsv
function
Description:
------------
Like pinkgothic at gmail dot com, 03-Apr-2007, I also found the
documentation mildly misleading and also lacking a basic description.
"The length parameter ... became optional in PHP 5"
It IS required with PHP 4:
array fgetcsv ( resource $handle , int $length [, string $delimiter [,
string $enclosure [, string $escape ]]] )
fgetcsv is a specialized combination of fgets() and split() that reads a
file and splits each record into an array based on $delimiter (default:
comma) but ignoring any delimiters within $enclosure (default:double
quotes)
$fp1=fopen($inputfile,"r");
while(!feof($fp1)){
$record = fgetcsv($fp1,1000);
// For example a csv record formatted as:
// ,"Abels",,"Karen D.","123, Test blvd, Apt
7","Anytown","PA","19123-1234","610,644-1234",,,,,"""Harry""",
// is stored as
print_r($record); // (partially shown here)
Array ( [0] => [1] => Abels [2] => [3] => Karen D. [4] => 123, Test blvd,
Apt 7 ...
[8] => 610,644-1234 ... [13] => "Harry" )
Any commas within a field were ignored and quotes within a field were
handled correctly.
--
Edit bug report at http://bugs.php.net/?id=45596&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45596&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45596&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45596&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45596&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=45596&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45596&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45596&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45596&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45596&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45596&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=45596&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=45596&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45596&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45596&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45596&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45596&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45596&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45596&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45596&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45596&r=mysqlcfg