mirror of
https://github.com/php/doc-zh.git
synced 2026-03-25 23:52:17 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/zh/trunk@327980 c90b9560-bf6c-de11-be94-00142212c4b1
141 lines
4.2 KiB
XML
141 lines
4.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- $Author$ -->
|
|
<!-- EN-Revision: b66067051c6fea8b168df6e79814be2efeca11eb Maintainer: dallas Status: ready -->
|
|
<refentry xml:id="function.array-intersect-assoc" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv> <refname>array_intersect_assoc</refname>
|
|
<refpurpose>带索引检查计算数组的交集</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>array_intersect_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>
|
|
<simpara>
|
|
<function>array_intersect_assoc</function> 返回一个数组,该数组包含了所有在
|
|
<parameter>array1</parameter> 中也同时出现在所有其它参数数组中的值。注意和
|
|
<function>array_intersect</function> 不同的是键名也用于比较。
|
|
</simpara>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>array1</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The array with master values to check.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>array2</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
An array to compare values against.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
要对比的数组变量的列表。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
返回一个数组,该数组包含了所有在
|
|
<parameter>array1</parameter> 中也同时出现在所有其它参数数组中的值。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>array_intersect_assoc</function> 例子</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
|
|
$array2 = array("a" => "green", "b" => "yellow", "blue", "red");
|
|
$result_array = array_intersect_assoc($array1, $array2);
|
|
print_r($result_array);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[a] => green
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<simpara>
|
|
上面例子中可以看到只有键值对 <literal>"a" =>
|
|
"green"</literal> 在两个数组中都存在从而被返回。值
|
|
<literal>"red"</literal> 没有被返回是因为在
|
|
<varname>$array1</varname> 中它的键名是 <literal>0</literal>
|
|
而在 <varname>$array2</varname> 中 <literal>"red"</literal>
|
|
的键名是 <literal>1</literal>,键 <literal>"b"</literal> 没有返回的原因是它的值和其他数组不同。
|
|
</simpara>
|
|
<simpara>
|
|
键值对 <literal>key => value</literal>
|
|
中的两个值仅在 <literal>(string) $elem1 === (string)
|
|
$elem2 </literal> 时被认为相等。也就是说使用了严格检查,字符串的表达必须相同。
|
|
<!-- TODO: example of it... -->
|
|
</simpara>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<simplelist>
|
|
<member><function>array_intersect</function></member>
|
|
<member><function>array_uintersect_assoc</function></member>
|
|
<member><function>array_intersect_uassoc</function></member>
|
|
<member><function>array_uintersect_uassoc</function></member>
|
|
<member><function>array_diff</function></member>
|
|
<member><function>array_diff_assoc</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
|
|
-->
|