mirror of
https://github.com/php/doc-ja.git
synced 2026-03-24 23:22:16 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@222583 c90b9560-bf6c-de11-be94-00142212c4b1
102 lines
3.3 KiB
XML
102 lines
3.3 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision: 1.8 $ -->
|
|
<!-- EN-Revision: 1.6 Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: shimooka -->
|
|
<refentry id="function.array-diff-assoc">
|
|
<refnamediv>
|
|
<refname>array_diff_assoc</refname>
|
|
<refpurpose>追加された添字の確認を含めて配列の差を計算する</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>説明</title>
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>array_diff_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>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>array_diff_assoc</function> は、
|
|
<parameter>array1</parameter> から他の引数の配列の中に現れない全ての値を含む
|
|
<type>array</type> を返します。
|
|
<function>array_diff</function> と異なり、
|
|
キーが比較に使用されることに注意してください。
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><function>array_diff_assoc</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
|
|
$array2 = array("a" => "green", "yellow", "red");
|
|
$result = array_diff_assoc($array1, $array2);
|
|
print_r($result);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[b] => brown
|
|
[c] => blue
|
|
[0] => red
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<simpara>
|
|
上の例で、<literal>"a" => "green"</literal> の組が両方の配列に現れており、
|
|
このため、この関数の出力には含まれていません。
|
|
これとは異なり、<literal>0 => "red"</literal> は出力の中にありますが、
|
|
これは、二番目の引数において <literal>"red"</literal> が
|
|
<literal>1</literal> というキーを有しているためです。
|
|
</simpara>
|
|
<simpara>
|
|
<emphasis>key => value</emphasis> の組からの二つの値は、
|
|
<literal>(string) $elem1 === (string) $elem2 </literal>
|
|
が成り立つ場合のみ等しいと見なされます。
|
|
言い替えると、厳密なチェックが行われるため、
|
|
文字列表現が同じである必要があります。
|
|
<!-- TODO: example of it... -->
|
|
</simpara>
|
|
<note>
|
|
<simpara>
|
|
この関数は、N 次元配列の一次元だけを調べることに注意してください。
|
|
もちろん、例えば、
|
|
<literal>array_diff_assoc($array1[0], $array2[0]);</literal>
|
|
とすることにより、より深い次元でチェックを行うことも可能です。
|
|
</simpara>
|
|
</note>
|
|
<para>
|
|
<function>array_diff</function>、
|
|
<function>array_intersect</function> および
|
|
<function>array_intersect_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
|
|
-->
|