mirror of
https://github.com/php/doc-es.git
synced 2026-04-25 16:18:09 +02:00
4a2bed8052
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@297985 c90b9560-bf6c-de11-be94-00142212c4b1
212 lines
6.5 KiB
XML
212 lines
6.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: n/a Maintainer: lboshell Status: ready -->
|
|
<refentry xml:id="function.array-udiff-uassoc" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>array_udiff_uassoc</refname>
|
|
<refpurpose>Computa la diferencia entre matrices con un chequeo de índices
|
|
adicional, comparando los datos y los índices con una llamada de
|
|
retorno</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>array_udiff_uassoc</methodname>
|
|
<methodparam><type>array</type><parameter>matriz1</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter>matriz2</parameter></methodparam>
|
|
<methodparam choice="opt"><type>array</type><parameter> ...</parameter></methodparam>
|
|
<methodparam><type>callback</type><parameter>func_comparacion_datos</parameter></methodparam>
|
|
<methodparam><type>callback</type><parameter>func_comparacion_claves</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Computa la diferencia de matrices con un chequeo de índices adicional,
|
|
comparando los datos por medio de una función llamada de retorno.
|
|
</para>
|
|
<para>
|
|
Note que las claves son usadas en la comparación, a diferencia de
|
|
<function>array_diff</function> y <function>array_udiff</function>.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>matriz1</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
La primera matriz.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>matriz2</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
La segunda matriz.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>func_comparacion_datos</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
La función de comparación usada como llamada de retorno.
|
|
</para>
|
|
<para>
|
|
Para la comparación, se usa la llamada de retorno indicada por el
|
|
usuario. Ésta debe devolver un entero menor que, igual, o mayor que
|
|
cero si el primer argumento es considerado como menor, igual, o mayor
|
|
que el segundo, respectivamente.
|
|
</para>
|
|
<para>
|
|
La comparación de los datos de las matrices es realizada usando una
|
|
llamada de retorno entregada por el usuario:
|
|
<parameter>func_comparacion_datos</parameter>. En este sentido, su
|
|
comportamiento es el opuesto al de
|
|
<function>array_diff_assoc</function>, quien usa una función interna
|
|
para la comparación.
|
|
comparison.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>func_comparacion_claves</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
La comparación de claves (índices) es realizada también por la
|
|
llamada de retorno <parameter>func_comparacion_claves</parameter>.
|
|
Este comportamiento contrasta con lo que hace
|
|
<function>array_udiff_assoc</function>, ya que ésta compara los
|
|
índices usando una función interna.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Devuelve un valor tipo <type>array</type> que contiene todos los valores
|
|
de <parameter>matriz1</parameter> que no están presentes en ninguno de
|
|
los otros argumentos.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <function>array_udiff_uassoc</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
class cr {
|
|
private $miembro_privado;
|
|
function cr($val)
|
|
{
|
|
$this->miembro_privado = $val;
|
|
}
|
|
|
|
static function func_comp_cr($a, $b)
|
|
{
|
|
if ($a->miembro_privado === $b->miembro_privado) return 0;
|
|
return ($a->miembro_privado > $b->miembro_privado)? 1:-1;
|
|
}
|
|
|
|
static function func_comp_claves($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),);
|
|
|
|
$resultado = array_udiff_uassoc($a, $b, array("cr", "func_comp_cr"), array("cr", "func_comp_claves"));
|
|
print_r($resultado);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[0.1] => cr Object
|
|
(
|
|
[miembro_privado:private] => 9
|
|
)
|
|
|
|
[0.5] => cr Object
|
|
(
|
|
[miembro_privado:private] => 12
|
|
)
|
|
|
|
[0] => cr Object
|
|
(
|
|
[miembro_privado:private] => 23
|
|
)
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<simpara>
|
|
En nuestro ejemplo anterior, puede ver que la pareja <literal>"1" =>
|
|
new cr(4)</literal> está presente en ambas matrices, y por lo tanto no
|
|
hace parte de la salida de la función. Tenga en cuenta que debe
|
|
especificar 2 llamadas de retorno.
|
|
</simpara>
|
|
</refsect1>
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<simpara>
|
|
Por favor note que esta función únicamente chequea una dimensión de una
|
|
matriz n-dimensional. Por supuesto, puede chequear dimensiones más
|
|
profundas usando, por ejemplo, <literal>array_udiff_uassoc($matriz1[0],
|
|
$matriz2[0], "func_comparacion_datos",
|
|
"func_comparacion_claves");</literal>.
|
|
</simpara>
|
|
</note>
|
|
</refsect1>
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>array_diff</function></member>
|
|
<member><function>array_diff_assoc</function></member>
|
|
<member><function>array_udiff</function></member>
|
|
<member><function>array_udiff_assoc</function></member>
|
|
<member><function>array_intersect</function></member>
|
|
<member><function>array_intersect_assoc</function></member>
|
|
<member><function>array_uintersect</function></member>
|
|
<member><function>array_uintersect_assoc</function></member>
|
|
<member><function>array_uintersect_uassoc</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:"../../../../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
|
|
-->
|