cvs: phpdoc-ja /reference/array/functions array-diff-key.xml array-diff-uassoc.xml array-diff-ukey.xml array-intersect-key.xml
array-intersect-uassoc.xml array-intersect-ukey.xml array-product.xml array-udiff-assoc.xml array-udiff-uassoc.xml array-udiff.xml
array-uintersect-assoc.xml array-uintersect-uassoc.xml array-uintersect.xml array-walk-recursive.xml

From: Date: Sun, 07 Aug 2005 06:33:15 +0000
Subject: cvs: phpdoc-ja /reference/array/functions array-diff-key.xml array-diff-uassoc.xml array-diff-ukey.xml array-intersect-key.xml
array-intersect-uassoc.xml array-intersect-ukey.xml array-product.xml array-udiff-assoc.xml array-udiff-uassoc.xml array-udiff.xml
array-uintersect-assoc.xml array-uintersect-uassoc.xml array-uintersect.xml array-walk-recursive.xml
Groups: php.doc.ja 
Request: Send a blank email to doc-ja+get-1110@lists.php.net to get a copy of this message
takagi Sun Aug 7 02:33:15 2005 EDT Added files: /phpdoc-ja/reference/array/functions array-walk-recursive.xml array-uintersect.xml array-uintersect-uassoc.xml array-uintersect-assoc.xml array-udiff.xml array-udiff-uassoc.xml array-udiff-assoc.xml array-product.xml array-intersect-ukey.xml array-intersect-uassoc.xml array-intersect-key.xml array-diff-ukey.xml array-diff-uassoc.xml array-diff-key.xml Log: added japanese manual.

http://cvs.php.net/co.php/phpdoc-ja/reference/array/functions/array-walk-recursive.xml?r=1.1&p=1 Index: phpdoc-ja/reference/array/functions/array-walk-recursive.xml +++ phpdoc-ja/reference/array/functions/array-walk-recursive.xml <?xml version='1.0' encoding='utf-8'?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.8 Maintainer: takagi Status: ready --> <refentry id="function.array-walk-recursive"> <refnamediv> <refname>array_walk_recursive</refname> <refpurpose> 配列の全ての要素に、ユーザー関数を再帰的に適用する </refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>bool</type><methodname>array_walk_recursive</methodname> <methodparam><type>array</type><parameter role="reference">input</parameter></methodparam> <methodparam><type>callback</type><parameter>funcname</parameter></methodparam> <methodparam choice="opt"><type>mixed</type><parameter>userdata</parameter></methodparam> </methodsynopsis> <simpara> <parameter>input</parameter> 配列の各要素にユーザ定義関数 <parameter>funcname</parameter>を適用します。 この関数は配列の要素内を再帰的にたどっていきます。通常、 <parameter>funcname</parameter> は引数を二つとります。 <parameter>input</parameter> パラメータの値が最初の引数、 キー/添字は二番目の引数となります。 オプションの <parameter>userdata</parameter> パラメータが指定された場合、 コールバック関数 <parameter>funcname</parameter> への三番目の引数として 渡されます。 </simpara> <simpara> &return.success; </simpara> <note> <para> <parameter>funcname</parameter> により配列の値そのものを変更する必要が ある場合、<parameter>funcname</parameter> の最初の引数は <link linkend="language.references">参照</link>として 渡す必要があります。この場合、配列の要素に加えた変更は、 配列自体に対して行われます。 </para> </note> <para> <example> <title><function>array_walk_recursive</function> の例</title> <programlisting role="php"> <![CDATA[ <?php $sweet = array('a' => 'apple', 'b' => 'banana'); $fruits = array('sweet' => $sweet, 'sour' => 'lemon'); function test_print($item, $key) { echo "$key holds $item\n"; } array_walk_recursive($fruits, 'test_print'); ?> ]]> </programlisting> &example.outputs; <screen role="php"> <![CDATA[ a holds apple b holds banana sour holds lemon ]]> </screen> <para> キー 'sweet' が表示されないことにお気づきでしょう。<type>array</type> を要素として持つキーは関数に渡されません。 </para> </example> </para> <simpara> <function>array_walk</function> および &seealso.callback; も参照ください。 </simpara> </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-ja/reference/array/functions/array-uintersect.xml?r=1.1&p=1 Index: phpdoc-ja/reference/array/functions/array-uintersect.xml +++ phpdoc-ja/reference/array/functions/array-uintersect.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.4 Maintainer: takagi Status: ready --> <refentry id="function.array-uintersect"> <refnamediv> <refname>array_uintersect</refname> <refpurpose>データの比較にコールバック関数を用い、配列の共通項を計算する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>array</type><methodname>array_uintersect</methodname> <methodparam><type>array</type><parameter>array1</parameter></methodparam> <methodparam><type>array</type><parameter>array2</parameter></methodparam> <methodparam choice="opt"><type>array</type><parameter> ...</parameter></methodparam> <methodparam><type>callback</type><parameter>data_compare_func</parameter></methodparam> </methodsynopsis> <para> <function>array_uintersect</function> は、他の全ての引数に存在する <parameter>array1</parameter> の値を全て有する配列を返します。 データはコールバック関数を用いて比較されます。 </para> <para> <example> <title><function>array_uintersect</function> の例</title> <programlisting role="php"> <![CDATA[ <?php $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "GREEN", "B" => "brown", "yellow", "red"); print_r(array_uintersect($array1, $array2, "strcasecmp")); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Array ( [a] => green [b] => brown [0] => red ) ]]> </screen> </example> </para> <para> 比較は、ユーザが指定したコールバック関数を利用して行われます。 この関数は、1 つめの引数が 2 つめより小さい / 等しい / 大きい 場合にそれぞれ 負の数 / ゼロ / 正の数 を返す必要があります。 </para> <para> <function>array_intersect</function>, <function>array_uintersect_assoc</function>, <function>array_intersect_uassoc</function> および <function>array_uintersect_uassoc</function> も参照ください。 </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-ja/reference/array/functions/array-uintersect-uassoc.xml?r=1.1&p=1 Index: phpdoc-ja/reference/array/functions/array-uintersect-uassoc.xml +++ phpdoc-ja/reference/array/functions/array-uintersect-uassoc.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.4 Maintainer: takagi Status: ready --> <refentry id="function.array-uintersect-uassoc"> <refnamediv> <refname>array_uintersect_uassoc</refname> <refpurpose>データと添字の比較にコールバック関数を用い、 追加された添字の確認も含めて配列の共通項を計算する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>array</type><methodname>array_uintersect_uassoc</methodname> <methodparam><type>array</type><parameter>array1</parameter></methodparam> <methodparam><type>array</type><parameter>array2</parameter></methodparam> <methodparam choice="opt"><type>array</type><parameter> ...</parameter></methodparam> <methodparam><type>callback</type><parameter>data_compare_func</parameter></methodparam> <methodparam><type>callback</type><parameter>key_compare_func</parameter></methodparam> </methodsynopsis> <para> <function>array_uintersect_uassoc</function> は、全ての引数に現れる <parameter>array1</parameter> の全ての値を含む配列を返します。 <function>array_uintersect</function>と異なり、キーが比較に使用される ことに注意してください。データと添字はコールバック関数を用いて比較されます。 </para> <para> <example> <title><function>array_uintersect_uassoc</function> の例</title> <programlisting role="php"> <![CDATA[ <?php $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "GREEN", "B" => "brown", "yellow", "red"); print_r(array_uintersect_uassoc($array1, $array2, "strcasecmp", "strcasecmp")); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Array ( [a] => green [b] => brown ) ]]> </screen> </example> </para> <para> 比較は、ユーザが指定したコールバック関数を利用して行われます。 この関数は、1 つめの引数が 2 つめより小さい / 等しい / 大きい 場合にそれぞれ 負の数 / ゼロ / 正の数 を返す必要があります。 </para> <para> <function>array_uintersect</function>, <function>array_intersect_assoc</function>, <function>array_intersect_uassoc</function> および <function>array_uintersect_assoc</function> も参照ください。 </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-ja/reference/array/functions/array-uintersect-assoc.xml?r=1.1&p=1 Index: phpdoc-ja/reference/array/functions/array-uintersect-assoc.xml +++ phpdoc-ja/reference/array/functions/array-uintersect-assoc.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.4 Maintainer: takagi Status: ready --> <refentry id="function.array-uintersect-assoc"> <refnamediv> <refname>array_uintersect_assoc</refname> <refpurpose>データの比較にコールバック関数を用い、 追加された添字の確認も含めて配列の共通項を計算する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>array</type><methodname>array_uintersect_assoc</methodname> <methodparam><type>array</type><parameter>array1</parameter></methodparam> <methodparam><type>array</type><parameter>array2</parameter></methodparam> <methodparam choice="opt"><type>array</type><parameter> ...</parameter></methodparam> <methodparam><type>callback</type><parameter>data_compare_func</parameter></methodparam> </methodsynopsis> <para> <function>array_uintersect_assoc</function> は、全ての引数に現れる <parameter>array1</parameter> の全ての値を含む配列を返します。 <function>array_uintersect</function>と異なり、キーが比較に使用される ことに注意してください。データはコールバック関数を用いて比較されます。 </para> <para> <example> <title><function>array_uintersect_assoc</function> の例</title> <programlisting role="php"> <![CDATA[ <?php $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "GREEN", "B" => "brown", "yellow", "red"); print_r(array_uintersect_assoc($array1, $array2, "strcasecmp")); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Array ( [a] => green ) ]]> </screen> </example> </para> <para> 比較は、ユーザが指定したコールバック関数を利用して行われます。 この関数は、1 つめの引数が 2 つめより小さい / 等しい / 大きい 場合にそれぞれ 負の数 / ゼロ / 正の数 を返す必要があります。 </para> <para> <function>array_uintersect</function>, <function>array_intersect_assoc</function>, <function>array_intersect_uassoc</function> および <function>array_uintersect_uassoc</function> も参照ください。 </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-ja/reference/array/functions/array-udiff.xml?r=1.1&p=1 Index: phpdoc-ja/reference/array/functions/array-udiff.xml +++ phpdoc-ja/reference/array/functions/array-udiff.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.10 Maintainer: takagi Status: ready --> <refentry id="function.array-udiff"> <refnamediv> <refname>array_udiff</refname> <refpurpose>データの比較にコールバック関数を用い、配列の差を計算する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>array</type><methodname>array_udiff</methodname> <methodparam><type>array</type><parameter>array1</parameter></methodparam> <methodparam><type>array</type><parameter>array2</parameter></methodparam> <methodparam choice="opt"><type>array</type><parameter> ...</parameter></methodparam> <methodparam><type>callback</type><parameter>data_compare_func</parameter></methodparam> </methodsynopsis> <para> <function>array_udiff</function> は、他の引数のいずれにも存在しない <parameter>array1</parameter> の値の全てを有する配列を返します。 キーと値の関係は維持されることに注意してください。 データの比較には <parameter>data_compare_func</parameter> が用いられます。 この関数は、1 つめの引数が 2 つめより小さい / 等しい / 大きい 場合にそれぞれ 負の数 / ゼロ / 正の数 を返す必要があります。 この関数は <function>array_diff</function> に似ていますが、こちらは データの比較に内部関数を利用します。 </para> <para> <example> <title><function>array_udiff</function> の例</title> <programlisting role="php"> <![CDATA[ <?php class cr { private $priv_member; function cr($val) { $this->priv_member = $val; } function comp_func_cr($a, $b) { if ($a->priv_member === $b->priv_member) return 0; return ($a->priv_member > $b->priv_member)? 1:-1; } } $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),); $result = array_udiff($a, $b, array("cr", "comp_func_cr")); print_r($result); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Array ( [0.5] => cr Object ( [priv_member:private] => 12 ) [0] => cr Object ( [priv_member:private] => 23 ) ) ]]> </screen> </example> </para> <note> <simpara> この関数は n 次元配列の一つの次元しかチェックしないことに注意してください。 もちろん、<literal>array_udiff($array1[0], $array2[0], "data_compare_func");</literal> のようにすることでより深い次元でのチェックもできます。 </simpara> </note> <para> <function>array_diff</function>, <function>array_diff_assoc</function>, <function>array_diff_uassoc</function>, <function>array_udiff_assoc</function>, <function>array_udiff_uassoc</function>, <function>array_intersect</function>, <function>array_intersect_assoc</function>, <function>array_uintersect</function>, <function>array_uintersect_assoc</function> および <function>array_uintersect_uassoc</function> も参照ください。 </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-ja/reference/array/functions/array-udiff-uassoc.xml?r=1.1&p=1 Index: phpdoc-ja/reference/array/functions/array-udiff-uassoc.xml +++ phpdoc-ja/reference/array/functions/array-udiff-uassoc.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.11 Maintainer: takagi Status: ready --> <refentry id="function.array-udiff-uassoc"> <refnamediv> <refname>array_udiff_uassoc</refname> <refpurpose>データと添字の比較にコールバック関数を用い、 追加された添字の確認を含めて配列の差を計算する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>array</type><methodname>array_udiff_uassoc</methodname> <methodparam><type>array</type><parameter>array1</parameter></methodparam> <methodparam><type>array</type><parameter>array2</parameter></methodparam> <methodparam choice="opt"><type>array</type><parameter> ...</parameter></methodparam> <methodparam><type>callback</type><parameter>data_compare_func</parameter></methodparam> <methodparam><type>callback</type><parameter>key_compare_func</parameter></methodparam> </methodsynopsis> <para> <function>array_udiff_uassoc</function> は、 <parameter>array1</parameter> から他の引数の配列の中に現れない全ての 値を含む<type>array</type> を返します。 <function>array_diff</function> や <function>array_udiff</function> と異なり、キーが比較に使用されることに注意してください。 配列のデータの比較は、ユーザが指定したコールバック <parameter>data_compare_func</parameter> を用いて行われます。 この点で、<function>array_diff_assoc</function> は反対の動作、つまり 内部関数を利用した比較を行います。キー(添字)の比較は、コールバック関数 <parameter>key_compare_func</parameter> で行われます。 <function>array_udiff_assoc</function> では後者の比較が内部関数で 行われるという点で、この関数とは異なります。 </para> <para> <example> <title><function>array_udiff_uassoc</function> の例</title> <programlisting role="php"> <![CDATA[ <?php class cr { private $priv_member; function cr($val) { $this->priv_member = $val; } function comp_func_cr($a, $b) { if ($a->priv_member === $b->priv_member) return 0; return ($a->priv_member > $b->priv_member)? 1:-1; } function comp_func_key($a, $b) { if ($a === $b) return 0; return ($a > $b)? 1:-1; } } $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),); $result = array_udiff_uassoc($a, $b, array("cr", "comp_func_cr"), array("cr", "comp_func_key")); print_r($result); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Array ( [0.1] => cr Object ( [priv_member:private] => 9 ) [0.5] => cr Object ( [priv_member:private] => 12 ) [0] => cr Object ( [priv_member:private] => 23 ) ) ]]> </screen> </example> </para> <simpara> 上の例で、<literal>"1" =&gt; new cr(4)</literal> の組み合わせが両方の 配列にあること、そしてそれが関数の出力に含まれていないことが確認できます。 コールバック関数を 2 つ指定しなければならないことに注意してください。 </simpara> <simpara> 比較は、ユーザが指定したコールバック関数を用いて行います。 この関数は、1 つめの引数が 2 つめより小さい / 等しい / 大きい 場合にそれぞれ 負の数 / ゼロ / 正の数 を返す必要があります。 </simpara> <note> <simpara> この関数は n 次元配列の一つの次元しかチェックしないことに注意してください。 もちろん、<literal>array_udiff_uassoc($array1[0], $array2[0], "data_compare_func", "key_compare_func");</literal> のようにすることでより深い次元でのチェックもできます。 </simpara> </note> <para> <function>array_diff</function>, <function>array_diff_assoc</function>, <function>array_diff_uassoc</function>, <function>array_udiff</function>, <function>array_udiff_assoc</function>, <function>array_intersect</function>, <function>array_intersect_assoc</function>, <function>array_uintersect</function>, <function>array_uintersect_assoc</function> および <function>array_uintersect_uassoc</function> も参照ください。 </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-ja/reference/array/functions/array-udiff-assoc.xml?r=1.1&p=1 Index: phpdoc-ja/reference/array/functions/array-udiff-assoc.xml +++ phpdoc-ja/reference/array/functions/array-udiff-assoc.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.9 Maintainer: takagi Status: ready --> <refentry id="function.array-udiff-assoc"> <refnamediv> <refname>array_udiff_assoc</refname> <refpurpose>データの比較にコールバック関数を用い、 追加された添字の確認を含めて配列の差を計算する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>array</type><methodname>array_udiff_assoc</methodname> <methodparam><type>array</type><parameter>array1</parameter></methodparam> <methodparam><type>array</type><parameter>array2</parameter></methodparam> <methodparam choice="opt"><type>array</type><parameter> ...</parameter></methodparam> <methodparam><type>callback</type><parameter>data_compare_func</parameter></methodparam> </methodsynopsis> <para> <function>array_udiff_assoc</function> は、 <parameter>array1</parameter> から他の引数の配列の中に現れない全ての 値を含む<type>array</type> を返します。 <function>array_diff</function> や <function>array_udiff</function> と異なり、キーが比較に使用されることに注意してください。 配列のデータの比較は、ユーザが指定したコールバックを用いて行われます。 この点で、<function>array_diff_assoc</function> は反対の動作、つまり 内部関数を利用した比較を行います。 </para> <para> <example> <title><function>array_udiff_assoc</function> の例</title> <programlisting role="php"> <![CDATA[ <?php class cr { private $priv_member; function cr($val) { $this->priv_member = $val; } function comp_func_cr($a, $b) { if ($a->priv_member === $b->priv_member) return 0; return ($a->priv_member > $b->priv_member)? 1:-1; } } $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),); $result = array_udiff_assoc($a, $b, array("cr", "comp_func_cr")); print_r($result); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Array ( [0.1] => cr Object ( [priv_member:private] => 9 ) [0.5] => cr Object ( [priv_member:private] => 12 ) [0] => cr Object ( [priv_member:private] => 23 ) ) ]]> </screen> </example> </para> <simpara> 上の例で、<literal>"1" =&gt; new cr(4)</literal> の組み合わせが両方の 配列にあること、そしてそれが関数の出力に含まれていないことが確認できます。 </simpara> <simpara> 比較は、ユーザが指定したコールバック関数を用いて行います。 この関数は、1 つめの引数が 2 つめより小さい / 等しい / 大きい 場合にそれぞれ 負の数 / ゼロ / 正の数 を返す必要があります。 </simpara> <note> <simpara> この関数は n 次元配列の一つの次元しかチェックしないことに注意してください。 もちろん、<literal>array_udiff_assoc($array1[0], $array2[0], "some_comparison_func");</literal> のようにすることでより深い次元でのチェックもできます。 </simpara> </note> <para> <function>array_diff</function>, <function>array_diff_assoc</function>, <function>array_diff_uassoc</function>, <function>array_udiff</function>, <function>array_udiff_uassoc</function>, <function>array_intersect</function>, <function>array_intersect_assoc</function>, <function>array_uintersect</function>, <function>array_uintersect_assoc</function> および <function>array_uintersect_uassoc</function> も参照ください。 </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-ja/reference/array/functions/array-product.xml?r=1.1&p=1 Index: phpdoc-ja/reference/array/functions/array-product.xml +++ phpdoc-ja/reference/array/functions/array-product.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.1 Maintainer: takagi Status: ready --> <refentry id="function.array-product"> <refnamediv> <refname>array_product</refname> <refpurpose> 配列の値の積を計算する </refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>number</type><methodname>array_product</methodname> <methodparam><type>array</type><parameter>array</parameter></methodparam> </methodsynopsis> <para> <function>array_product</function> は、配列の各要素の積を計算して integer または float で返します。 </para> <para> <example> <title><function>array_product</function> の例</title> <programlisting role="php"> <![CDATA[ <?php $a = array(2, 4, 6, 8); echo "product(a) = " . array_product($a) . "\n"; ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ product(a) = 384 ]]> </screen> </example> </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-ja/reference/array/functions/array-intersect-ukey.xml?r=1.1&p=1 Index: phpdoc-ja/reference/array/functions/array-intersect-ukey.xml +++ phpdoc-ja/reference/array/functions/array-intersect-ukey.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.3 Maintainer: takagi Status: ready --> <refentry id="function.array-intersect-ukey"> <refnamediv> <refname>array_intersect_ukey</refname> <refpurpose>キーを基準にし、コールバック関数を用いて 配列の共通項を計算する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>array</type><methodname>array_intersect_ukey</methodname> <methodparam><type>array</type><parameter>array1</parameter></methodparam> <methodparam><type>array</type><parameter>array2</parameter></methodparam> <methodparam choice="opt"><type>array</type><parameter>...</parameter></methodparam> <methodparam><type>callback</type><parameter>key_compare_func</parameter></methodparam> </methodsynopsis> <para> <function>array_intersect_ukey</function> は、他の全ての引数に存在する <parameter>array1</parameter>の値を全て有する配列を返します。 </para> <para> 比較は、ユーザが指定したコールバック関数を利用して行われます。 この関数は、1 つめの引数が 2 つめより小さい / 等しい / 大きい 場合にそれぞれ 負の数 / ゼロ / 正の数 を返す必要があります。 </para> <para> <example> <title><function>array_intersect_ukey</function> の例</title> <programlisting role="php"> <![CDATA[ <?php function key_compare_func($key1, $key2) { if ($key1 == $key2) return 0; else if ($key1 > $key2) return 1; else return -1; } $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); var_dump(array_intersect_ukey($array1, $array2, 'key_compare_func')); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ array(2) { ["blue"]=> int(1) ["green"]=> int(3) }) ]]> </screen> </example> </para> <para> この例では、両方の配列に存在するキーが <literal>'blue'</literal> と <literal>'green'</literal> だけであり、それが返されていることが わかります。また、ふたつの配列の間で <literal>'blue'</literal> と <literal>'green'</literal> に対応する値が違うことにも注意しましょう。 それでも一致していると判定されるのは、ただキーだけがチェックされている からです。返される値は <parameter>array1</parameter> のものです。 </para> <para> <function>array_diff</function>, <function>array_udiff</function> <function>array_diff_assoc</function>, <function>array_diff_uassoc</function>, <function>array_udiff_assoc</function>, <function>array_udiff_uassoc</function>, <function>array_diff_key</function>, <function>array_diff_ukey</function>, <function>array_intersect</function>, <function>array_intersect_assoc</function>, <function>array_intersect_uassoc</function> および <function>array_intersect_key</function> も参照ください。 </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-ja/reference/array/functions/array-intersect-uassoc.xml?r=1.1&p=1 Index: phpdoc-ja/reference/array/functions/array-intersect-uassoc.xml +++ phpdoc-ja/reference/array/functions/array-intersect-uassoc.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.4 Maintainer: takagi Status: ready --> <refentry id="function.array-intersect-uassoc"> <refnamediv> <refname>array_intersect_uassoc</refname> <refpurpose>追加された添字の確認も含め、コールバック関数を用いて 配列の共通項を確認する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>array</type><methodname>array_intersect_uassoc</methodname> <methodparam><type>array</type><parameter>array1</parameter></methodparam> <methodparam><type>array</type><parameter>array2</parameter></methodparam> <methodparam choice="opt"><type>array</type><parameter> ...</parameter></methodparam> <methodparam><type>callback</type><parameter>key_compare_func</parameter></methodparam> </methodsynopsis> <para> <function>array_intersect_uassoc</function> は、全ての引数に現れる <parameter>array1</parameter> の全ての値を含む配列を返します。 <function>array_intersect</function> と異なりキーが比較に使用される ことに注意してください。 </para> <para> 比較は、ユーザが指定したコールバック関数を利用して行われます。 この関数は、1 つめの引数が 2 つめより小さい / 等しい / 大きい 場合にそれぞれ 負の数 / ゼロ / 正の数 を返す必要があります。 </para> <para> <example> <title><function>array_intersect_uassoc</function> の例</title> <programlisting role="php"> <![CDATA[ <?php $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "GREEN", "B" => "brown", "yellow", "red"); print_r(array_intersect_uassoc($array1, $array2, "strcasecmp")); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Array ( [b] => brown ) ]]> </screen> </example> </para> <para> <function>array_intersect</function>, <function>array_intersect_assoc</function>, <function>array_uintersect_assoc</function>, <function>array_uintersect_uassoc</function>, <function>array_intersect_key</function> および <function>array_intersect_ukey</function> も参照ください。 </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-ja/reference/array/functions/array-intersect-key.xml?r=1.1&p=1 Index: phpdoc-ja/reference/array/functions/array-intersect-key.xml +++ phpdoc-ja/reference/array/functions/array-intersect-key.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.2 Maintainer: takagi Status: ready --> <refentry id="function.array-intersect-key"> <refnamediv> <refname>array_intersect_key</refname> <refpurpose>キーを基準にして配列の共通項を計算する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>array</type><methodname>array_intersect_key</methodname> <methodparam><type>array</type><parameter>array1</parameter></methodparam> <methodparam><type>array</type><parameter>array2</parameter></methodparam> <methodparam choice="opt"><type>array</type><parameter> ...</parameter></methodparam> </methodsynopsis> <para> <function>array_intersect_key</function> は、他の全ての引数に存在する <parameter>array1</parameter>の値を全て有する配列を返します。 </para> <para> <example> <title><function>array_intersect_key</function> の例</title> <programlisting role="php"> <![CDATA[ <?php $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); var_dump(array_intersect_key($array1, $array2)); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ array(2) { ["blue"]=> int(1) ["green"]=> int(3) }) ]]> </screen> </example> </para> <para> この例では、両方の配列に存在するキーが <literal>'blue'</literal> と <literal>'green'</literal> だけであり、それが返されていることが わかります。また、ふたつの配列の間で <literal>'blue'</literal> と <literal>'green'</literal> に対応する値が違うことにも注意しましょう。 それでも一致していると判定されるのは、ただキーだけがチェックされている からです。返される値は <parameter>array1</parameter> のものです。 </para> <para> 二つの要素は、 <literal>(string) $elem1 === (string) $elem2</literal>の場合のみ 等しいとみなされます。言い換えると、文字列表現が同じ場合となります。 </para> <para> <function>array_diff</function>, <function>array_udiff</function> <function>array_diff_assoc</function>, <function>array_diff_uassoc</function>, <function>array_udiff_assoc</function>, <function>array_udiff_uassoc</function>, <function>array_diff_key</function>, <function>array_diff_ukey</function>, <function>array_intersect</function>, <function>array_intersect_assoc</function>, <function>array_intersect_uassoc</function> および <function>array_intersect_ukey</function> も参照ください。 </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-ja/reference/array/functions/array-diff-ukey.xml?r=1.1&p=1 Index: phpdoc-ja/reference/array/functions/array-diff-ukey.xml +++ phpdoc-ja/reference/array/functions/array-diff-ukey.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.3 Maintainer: takagi Status: ready --> <refentry id="function.array-diff-ukey"> <refnamediv> <refname>array_diff_ukey</refname> <refpurpose>キーを基準にし、コールバック関数を用いて 配列の差を計算する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>array</type><methodname>array_diff_ukey</methodname> <methodparam><type>array</type><parameter>array1</parameter></methodparam> <methodparam><type>array</type><parameter>array2</parameter></methodparam> <methodparam choice="opt"><type>array</type><parameter> ...</parameter></methodparam> <methodparam><type>callback</type><parameter>key_compare_func</parameter></methodparam> </methodsynopsis> <para> <function>array_diff_ukey</function> は、<parameter>array1</parameter> から他の引数の配列の中に現れない全ての値を含む配列を返します。 キーと値の関係は維持されることに注意してください。この関数は <function>array_diff</function> に似ていますが、値ではなくキーを 用いて比較するという点が異なります。 </para> <para> 比較は、ユーザが指定したコールバック関数を利用して行われます。 この関数は、1 つめの引数が 2 つめより小さい / 等しい / 大きい 場合にそれぞれ 負の数 / ゼロ / 正の数 を返す必要があります。 </para> <para> <example> <title><function>array_diff_ukey</function> の例</title> <programlisting role="php"> <![CDATA[ <?php function key_compare_func($key1, $key2) { if ($key1 == $key2) return 0; else if ($key1 > $key2) return 1; else return -1; } $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); var_dump(array_diff_ukey($array1, $array2, 'key_compare_func')); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ array(2) { ["red"]=> int(2) ["purple"]=> int(4) } ]]> </screen> </example> </para> <note> <simpara> この関数は n 次元配列の一つの次元しかチェックしないことに注意してください。 もちろん、<literal>array_diff_ukey($array1[0], $array2[0], 'callback_func');</literal> のようにすることでより深い次元でのチェックもできます。 </simpara> </note> <para> <function>array_diff</function>, <function>array_udiff</function> <function>array_diff_assoc</function>, <function>array_diff_uassoc</function>, <function>array_udiff_assoc</function>, <function>array_udiff_uassoc</function>, <function>array_diff_key</function>, <function>array_intersect</function>, <function>array_intersect_assoc</function>, <function>array_intersect_uassoc</function>, <function>array_intersect_key</function> および <function>array_intersect_ukey</function> も参照ください。 </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-ja/reference/array/functions/array-diff-uassoc.xml?r=1.1&p=1 Index: phpdoc-ja/reference/array/functions/array-diff-uassoc.xml +++ phpdoc-ja/reference/array/functions/array-diff-uassoc.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- splitted from ./en/functions/array.xml, last change in rev 1.14 --> <!-- EN-Revision: 1.7 Maintainer: takagi Status: ready --> <refentry id="function.array-diff-uassoc"> <refnamediv> <refname>array_diff_uassoc</refname> <refpurpose> ユーザが指定したコールバック関数を利用し、 追加された添字の確認を含めて配列の差を計算する </refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>array</type><methodname>array_diff_uassoc</methodname> <methodparam><type>array</type><parameter>array1</parameter></methodparam> <methodparam><type>array</type><parameter>array2</parameter></methodparam> <methodparam choice="opt"><type>array</type><parameter>...</parameter></methodparam> <methodparam><type>callback</type><parameter>key_compare_func</parameter></methodparam> </methodsynopsis> <para> <function>array_diff_uassoc</function> は、 <parameter>array1</parameter> から他の引数の配列の中に現れない全ての 値を含む <type>array</type> を返します。 <function>array_diff</function> と異なりキーが比較に使用されることに 注意してください。 </para> <para> 比較は、ユーザが指定したコールバック関数を利用して行われます。 この関数は、1 つめの引数が 2 つめより小さい / 等しい / 大きい 場合にそれぞれ 負の数 / ゼロ / 正の数 を返す必要があります。 これが <function>array_diff_assoc</function> との相違点で、こちらは 比較のために内部関数を用いています。 </para> <para> <example> <title><function>array_diff_uassoc</function> の例</title> <programlisting role="php"> <![CDATA[ <?php function key_compare_func($a, $b) { if ($a === $b) { return 0; } return ($a > $b)? 1:-1; } $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "green", "yellow", "red"); $result = array_diff_uassoc($array1, $array2, "key_compare_func"); print_r($result); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Array ( [b] => brown [c] => blue [0] => red ) ]]> </screen> </example> </para> <simpara> この例で、<literal>"a" =&gt; "green"</literal> の組み合わせが両方の 配列に存在し、関数の出力には存在しないことが確認できます。 これとは異なり、<literal>0 =&gt; "red"</literal> は出力されています。 なぜなら 2 つめの引数の <literal>"red"</literal> は、キーが <literal>1</literal> だからです。 </simpara> <simpara> 2 つのインデックスが等しいかどうかは、ユーザが指定した コールバック関数で調べます。 </simpara> <note> <simpara> この関数は n 次元配列の一つの次元しかチェックしないことに注意してください。 もちろん、<literal>array_diff_uassoc($array1[0], $array2[0], "key_compare_func");</literal> のようにすることでより深い次元でのチェックもできます。 </simpara> </note> <para> <function>array_diff</function>, <function>array_diff_assoc</function>, <function>array_udiff</function>, <function>array_udiff_assoc</function>, <function>array_udiff_uassoc</function>, <function>array_intersect</function>, <function>array_intersect_assoc</function>, <function>array_uintersect</function>, <function>array_uintersect_assoc</function> および <function>array_uintersect_uassoc</function> も参照ください。 </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-ja/reference/array/functions/array-diff-key.xml?r=1.1&p=1 Index: phpdoc-ja/reference/array/functions/array-diff-key.xml +++ phpdoc-ja/reference/array/functions/array-diff-key.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.2 Maintainer: takagi Status: ready --> <refentry id="function.array-diff-key"> <refnamediv> <refname>array_diff_key</refname> <refpurpose>キーを基準にして配列の差を計算する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>array</type><methodname>array_diff_key</methodname> <methodparam><type>array</type><parameter>array1</parameter></methodparam> <methodparam><type>array</type><parameter>array2</parameter></methodparam> <methodparam choice="opt"><type>array</type><parameter> ...</parameter></methodparam> </methodsynopsis> <para> <function>array_diff_key</function> は、<parameter>array1</parameter> から他の引数の配列の中に現れない全ての値を含む配列を返します。 キーと値の関係は維持されることに注意してください。この関数は <function>array_diff</function> に似ていますが、値ではなくキーを 用いて比較するという点が異なります。 </para> <para> <example> <title><function>array_diff_key</function> の例</title> <programlisting role="php"> <![CDATA[ <?php $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); var_dump(array_diff_key($array1, $array2)); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ array(2) { ["red"]=> int(2) ["purple"]=> int(4) } ]]> </screen> </example> </para> <simpara> 二つの要素は、<literal>(string) $elem1 === (string) $elem2</literal> の場合のみ等しいと見なされます。言い換えると、文字列表現が同じ場合と なります。 </simpara> <note> <simpara> この関数は n 次元配列の一つの次元しかチェックしないことに注意してください。 もちろん、<literal>array_diff_key($array1[0], $array2[0]);</literal> のようにすることでより深い次元でのチェックもできます。 </simpara> </note> <para> <function>array_diff</function>, <function>array_udiff</function> <function>array_diff_assoc</function>, <function>array_diff_uassoc</function>, <function>array_udiff_assoc</function>, <function>array_udiff_uassoc</function>, <function>array_diff_ukey</function>, <function>array_intersect</function>, <function>array_intersect_assoc</function>, <function>array_intersect_uassoc</function>, <function>array_intersect_key</function> および <function>array_intersect_ukey</function> も参照ください。 </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:"../../../../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 -->
« previous php.doc.ja (#1110) next »