philip Thu Oct 17 21:48:11 2002 EDT
Modified files:
/phpdoc/en/reference/filesystem/functions fgetcsv.xml
Log:
Rewrote to hopefully make more sense. See also explode, file, and pack.
Moved "enclosure added in PHP 4.3.0" to a note.
Index: phpdoc/en/reference/filesystem/functions/fgetcsv.xml
diff -u phpdoc/en/reference/filesystem/functions/fgetcsv.xml:1.4
phpdoc/en/reference/filesystem/functions/fgetcsv.xml:1.5
--- phpdoc/en/reference/filesystem/functions/fgetcsv.xml:1.4 Sun May 26 22:16:07
2002
+++ phpdoc/en/reference/filesystem/functions/fgetcsv.xml Thu Oct 17 21:48:11
+2002
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/filesystem.xml, last change in rev 1.2 -->
<refentry id="function.fgetcsv">
<refnamediv>
@@ -19,20 +19,24 @@
Similar to <function>fgets</function> except that
<function>fgetcsv</function> parses the line it reads for fields
in <acronym>CSV</acronym> format and returns an array containing
- the fields read. The field delimiter is a comma, unless you
- specify another delimiter with the optional third parameter. The
- enclosure character is double quote, unless it is
- specified. <parameter>Delimiter</parameter> and
- <parameter>enclosure</parameter> cannot be null and only first
- character is used when they are specified.
+ the fields read. The optional third <parameter>delimiter</parameter>
+ parameter defaults as a comma. The optional <parameter>enclosure</parameter>
+ cannot be <type>null</type>, and is limited to one character. If
+ <parameter>enclosure</parameter> is more than one character, only the
+ first character is used.
</simpara>
+ <note>
+ <simpara>
+ The <parameter>enclosure</parameter> parameter was added in PHP 4.3.0.
+ </simpara>
+ </note>
<simpara>
- <parameter>Fp</parameter> must be a valid file pointer to a file
+ The <parameter>fp</parameter> parameter must be a valid file pointer to a file
successfully opened by <function>fopen</function>,
- <function>popen</function>, or <function>fsockopen</function>
+ <function>popen</function>, or <function>fsockopen</function>.
</simpara>
<simpara>
- <parameter>Length</parameter> must be greater than the longest
+ The <parameter>length</parameter> parameter must be greater than the longest
line to be found in the CSV file (allowing for trailing line-end characters).
</simpara>
<simpara>
@@ -42,34 +46,36 @@
<note>
<simpara>
A blank line in a CSV file will be returned as an array
- comprising a single &null; field, and will not be treated as an
- error.
- </simpara>
- <simpara>
- <parameter>enclosure</parameter> is added from PHP 4.3.0.
+ comprising a single <type>null</type> field, and will not be treated
+ as an error.
</simpara>
</note>
- <example>
- <title>
- <function>fgetcsv</function> example - Read and print entire
- contents of a CSV file
- </title>
- <programlisting role="php">
+ <para>
+ <example>
+ <title>Read and print the entire contents of a CSV file</title>
+ <programlisting role="php">
<![CDATA[
+<?php
$row = 1;
$fp = fopen ("test.csv","r");
while ($data = fgetcsv ($fp, 1000, ",")) {
$num = count ($data);
- print "<p> $num fields in line $row: <br>";
+ print "<p> $num fields in line $row: <br>\n";
$row++;
for ($c=0; $c < $num; $c++) {
- print $data[$c] . "<br>";
+ print $data[$c] . "<br>\n";
}
}
fclose ($fp);
+?>
]]>
- </programlisting>
- </example>
+ </programlisting>
+ </example>
+ </para>
+ <para>
+ See also <function>explode</function>, <function>file</function>,
+ and <function>pack</function>
+ </para>
</refsect1>
</refentry>
--
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php