mirror of
https://github.com/php/doc-ja.git
synced 2026-03-24 23:22:16 +01:00
- reference/mbstring/functions/mb-decode-numericentity.xml 1. php/doc-en@4e69a9f2b1 - reference/imap/functions/imap-headerinfo.xml 1. php/doc-en@4e69a9f2b1 - reference/ssh2/functions/ssh2-auth-pubkey-file.xml 1. php/doc-en@74ef2355c5 - reference/ssh2/functions/ssh2-connect.xml 1. php/doc-en@74ef2355c5 - reference/stream/functions/stream-filter-append.xml 1. php/doc-en@a684294e0b - reference/stream/functions/stream-filter-prepend.xml 1. php/doc-en@a684294e0b - reference/filesystem/functions/fgetcsv.xml 1. php/doc-en@e1fd0bef1d 2. php/doc-en@0a3648a718 3. `&warning.csv.escape-parameter;` の重複を削除(既訳のバグ修正) - reference/spl/splfileobject/fgetcsv.xml 1. php/doc-en@e1fd0bef1d 2. php/doc-en@3a89b55d11 3. php/doc-en@0a3648a718 - language/predefined/attributes/nodiscard.xml 1. php/doc-en@30bda33771 - reference/pdo_sqlite/pdo/sqlite/createfunction.xml 1. php/doc-en@28930349ca - reference/math/functions/fmod.xml 1. php/doc-en@54a788ca59 - reference/simplexml/simplexmlelement/addChild.xml 1. php/doc-en@dca2a8354f - reference/json/functions/json-last-error.xml 1. php/doc-en@058ea1e842 - features/commandline.xml 1. php/doc-en@96b10a9885 - appendices/migration85/incompatible.xml 1. php/doc-en@048982b729 2. php/doc-en@f81bbcf9d3 - reference/random/random/randomizer/getfloat.xml 1. php/doc-en@1ada637cc8 2. php/doc-en@423a1da63f - reference/mysqli/mysqli/multi-query.xml 1. php/doc-en@1beae37b69 - reference/image/functions/getimagesize.xml 1. php/doc-en@6bb90d24b2 - reference/curl/functions/curl-close.xml 1. php/doc-en@86c8ebd19e - reference/curl/functions/curl-share-close.xml 1. php/doc-en@29c3d13980 - reference/yaml/functions/yaml-parse-file.xml 1. php/doc-en@132d2a8d63 - reference/mysqli/mysqli/options.xml 1. php/doc-en@e309a62b16 2. MYSQLI_SERVER_PUBLIC_KEY の古い「PHP 5.5.0 以降」テキストを削除(既訳のバグ修正) - appendices/transports.xml 1. php/doc-en@ae90ecc932 - reference/soap/soapserver/addfunction.xml 1. php/doc-en@577239f64b - reference/var/functions/settype.xml 1. php/doc-en@8d49e302b4 - features/http-auth.xml 1. php/doc-en@cd4180557a
213 lines
7.3 KiB
XML
213 lines
7.3 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 0a3648a71895f35f570573d31ca9e003786aa993 Maintainer: masakielastic Status: ready -->
|
|
<!-- Credits: mumumu -->
|
|
<refentry xml:id="splfileobject.fgetcsv" xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
<refnamediv>
|
|
<refname>SplFileObject::fgetcsv</refname>
|
|
<refpurpose>ファイルから行を取り出し CSV フィールドとして処理する</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis role="SplFileObject">
|
|
<modifier>public</modifier> <type class="union"><type>array</type><type>false</type></type><methodname>SplFileObject::fgetcsv</methodname>
|
|
<methodparam choice="opt"><type>string</type><parameter>separator</parameter><initializer>","</initializer></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>enclosure</parameter><initializer>"\""</initializer></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>escape</parameter><initializer>"\\"</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<acronym>CSV</acronym> フォーマットのファイルから行を取り出し読み込まれたフィールドを含む配列を返します。
|
|
</para>
|
|
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('function.fgetcsv')/db:refsect1[@role='description']//db:note/.)">
|
|
<xi:fallback/>
|
|
</xi:include>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>separator</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
フィールドの区切り文字 (シングルバイト文字 1 文字のみ)。
|
|
デフォルトはカンマ(<literal>,</literal>)、 もしくは事前に
|
|
<methodname>SplFileObject::setCsvControl</methodname> を呼び出してセットされた値です。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>enclosure</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
フィールド囲み文字 (シングルバイト文字 1 文字のみ)。
|
|
デフォルトはダブルクォート(<literal>"</literal>)、もしくは事前に
|
|
<methodname>SplFileObject::setCsvControl</methodname> を呼び出してセットされた値です。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>escape</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
エスケープ文字 (シングルバイト文字 最大で1文字)。
|
|
デフォルトはバックスラッシュ(<literal>\</literal>)、 もしくは事前に
|
|
<methodname>SplFileObject::setCsvControl</methodname> を呼び出してセットされた値です。
|
|
空文字列(<literal>""</literal>)の場合、(RFC 4180 に準拠していない) 独自仕様のエスケープ機構が無効になります。
|
|
</para>
|
|
<xi:include xpointer="function.fgetcsv..warn.escape.parameter"/>
|
|
<warning>
|
|
<simpara>
|
|
PHP 8.4.0 以降では、<parameter>escape</parameter>
|
|
のデフォルト値に依存することは非推奨となりました。
|
|
位置指定の引数か、<link linkend="functions.named-arguments">名前付き引数</link>を使用するか、
|
|
あるいは <methodname>SplFileObject::setCsvControl</methodname>
|
|
を呼び出して、明示的に指定する必要があります。
|
|
</simpara>
|
|
</warning>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
&warning.csv.escape-parameter;
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
読み込まれたフィールドを含む数値添字配列もしくはエラーのときは &false; を返します。
|
|
</para>
|
|
<note>
|
|
<para>
|
|
CSV ファイルの空白行は <constant>SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE</constant> を使わない限り単独の &null; フィールドで構成される配列として返され、この場合空白行は読み飛ばされます。
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('function.fgetcsv')/db:refsect1[@role='errors']/.)">
|
|
<xi:fallback/>
|
|
</xi:include>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('function.fgetcsv')/db:refsect1[@role='changelog']//db:row[db:entry[text()='8.4.0']]/.)">
|
|
<xi:fallback/>
|
|
</xi:include>
|
|
<row>
|
|
<entry>7.4.0</entry>
|
|
<entry>
|
|
<parameter>escape</parameter> パラメータは空文字列を受け入れるようになりました。
|
|
この場合、(RFC 4180 に準拠していない) 独自仕様のエスケープ機構が無効になります。
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><methodname>SplFileObject::fgetcsv</methodname> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$file = new SplFileObject("data.csv");
|
|
while (!$file->eof()) {
|
|
var_dump($file->fgetcsv());
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><constant>SplFileObject::READ_CSV</constant> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$file = new SplFileObject("animals.csv");
|
|
$file->setFlags(SplFileObject::READ_CSV);
|
|
foreach ($file as $row) {
|
|
list($animal, $class, $legs) = $row;
|
|
printf("A %s is a %s with %d legs\n", $animal, $class, $legs);
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>animals.csv の内容</para>
|
|
<programlisting role="txt">
|
|
<![CDATA[
|
|
crocodile,reptile,4
|
|
dolphin,mammal,0
|
|
duck,bird,2
|
|
koala,mammal,4
|
|
salmon,fish,0
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
A crocodile is a reptile with 4 legs
|
|
A dolphin is a mammal with 0 legs
|
|
A duck is a bird with 2 legs
|
|
A koala is a mammal with 4 legs
|
|
A salmon is a fish with 0 legs
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<simplelist>
|
|
<member><methodname>SplFileObject::fputcsv</methodname></member>
|
|
<member><methodname>SplFileObject::setCsvControl</methodname></member>
|
|
<member><methodname>SplFileObject::getCsvControl</methodname></member>
|
|
<member><methodname>SplFileObject::setFlags</methodname></member>
|
|
<member><constant>SplFileObject::READ_CSV</constant></member>
|
|
<member><methodname>SplFileObject::current</methodname></member>
|
|
<member><function>fputcsv</function></member>
|
|
<member><function>fgetcsv</function></member>
|
|
<member><function>str_getcsv</function></member>
|
|
</simplelist>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|