1
0
mirror of https://github.com/php/doc-es.git synced 2026-03-25 16:02:13 +01:00
Files
archived-doc-es/reference/array/functions/array-intersect-key.xml
Enrique Garcia Briones e1efdb6c9e sync con version inglesa
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@172353 c90b9560-bf6c-de11-be94-00142212c4b1
2004-11-09 18:59:09 +00:00

101 lines
3.4 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- EN-Revision: 1.2 Maintainer: baoengb Status: ready -->
<refentry id="function.array-intersect-key">
<refnamediv>
<refname>array_intersect_key</refname>
<refpurpose>Calcula la intersecci&oacute;n de matrices usando las llaves
para la comparaci&oacute;n</refpurpose>
</refnamediv>
<refsect1>
<title>Descripci&oacute;n</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> regresa una matriz conteniendo
todos los valores de <parameter>array1</parameter> los cuales tienen llaves
que est&aacute;n presentes en todos los argumentos.
</para>
<para>
<example>
<title>Ejemplo <function>array_intersect_key</function></title>
<programlisting role="php">
<![CDATA[
<?php
$array1 = array('azul' => 1, 'rojo' => 2, 'verde' => 3, 'morado' => 4);
$array2 = array('verde' => 5, 'azul' => 6, 'amarillo' => 7, 'cyan' => 8);
var_dump(array_intersect_key($array1, $array2));
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(2) {
["azul"]=>
int(1)
["verde"]=>
int(3)
})
]]>
</screen>
</example>
</para>
<para>
En nuestro ejemplo puede ver que s&oacute;lo las llaves <literal>'azul'</literal>
y <literal>'verde'</literal> est&aacute;n presentes en ambas matrices y por
lo tanto son regresadas. Tambi&acute;n note que los valores para las llaves
<literal>'azul'</literal> y <literal>'verde'</literal> son diferentes en las
dos matrices. A&uacute;n as&iacute; siguen coincidiendo porque se hace
la comparaci&oacute;n s&oacute;lo en las llaves. Los valores regresados son
aquellos de <parameter>array1</parameter>.
</para>
<para>
Las dos llaves del par <literal>key =&gt; value</literal>, son considerados
iguales solo si <literal>(string) $key1 === (string) $key2 </literal>. En
otras palabras se hace un chequeo estricto del tipo de dato de tal manera que
la representaci&oacute;n de la cadena debe ser la misma.
</para>
<para>
Vea tambi&eacute;n <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> y
<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
-->