mirror of
https://github.com/php/doc-ja.git
synced 2026-03-27 00:22:08 +01:00
190 lines
5.5 KiB
XML
Executable File
190 lines
5.5 KiB
XML
Executable File
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 6330e4d73192c49a6867c6bbc3cbf09d63a1e36a Maintainer: takagi Status: ready -->
|
|
<!-- Credits: mumumu -->
|
|
<refentry xml:id="function.str-getcsv" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>str_getcsv</refname>
|
|
<refpurpose>
|
|
CSV 文字列をパースして配列に格納する
|
|
</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>str_getcsv</methodname>
|
|
<methodparam><type>string</type><parameter>string</parameter></methodparam>
|
|
<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>
|
|
<note>
|
|
<para>
|
|
この関数はロケール設定を考慮します。もし <varname>LC_CTYPE</varname>
|
|
が例えば <literal>en_US.UTF-8</literal> の場合、
|
|
1 バイトエンコーディングの文字列は間違って読み込まれるかもしれません。
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>string</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
パースする文字列。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>separator</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
フィールド区切り文字 (シングルバイト文字 1 文字のみ)。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>enclosure</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
フィールド囲み文字 (シングルバイト文字 1 文字のみ)。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>escape</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
エスケープ文字 (シングルバイト文字 最大1文字)。デフォルトはバックスラッシュ
|
|
(<literal>\</literal>)。
|
|
空文字列 (<literal>""</literal>) を指定すると、
|
|
(RFC 4180 に準拠していない) 独自仕様のエスケープ機構を無効にします。
|
|
</para>
|
|
<note>
|
|
<simpara>
|
|
通常、 <parameter>enclosure</parameter> の文字は、
|
|
フィールドの中では二回出力されることでエスケープされます。
|
|
しかし、<parameter>escape</parameter>
|
|
の文字を代わりに使うこともできます。
|
|
よって、デフォルト値 <literal>""</literal>
|
|
および <literal>\"</literal> は同じ意味になります。
|
|
<parameter>enclosure</parameter> 文字をエスケープすることを許可する以外に、
|
|
<parameter>escape</parameter> 文字は特別な意味を何ら持ちません;
|
|
つまり、自分自身をエスケープすることすら意味しません。
|
|
</simpara>
|
|
</note>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
読み込んだフィールドの内容を配列で返します。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<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><function>str_getcsv</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$string = 'PHP,Java,Python,Kotlin,Swift';
|
|
$data = str_getcsv($string);
|
|
|
|
var_dump($data);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
array(5) {
|
|
[0]=>
|
|
string(3) "PHP"
|
|
[1]=>
|
|
string(4) "Java"
|
|
[2]=>
|
|
string(6) "Python"
|
|
[3]=>
|
|
string(6) "Kotlin"
|
|
[4]=>
|
|
string(5) "Swift"
|
|
}
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>fgetcsv</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</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
|
|
-->
|