mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-24 07:02:09 +01:00
* Updates to abandoned/outdated pages in reference/array/functions/ * Updates to outdated/abandoned pages and new translations in reference/classobj/ * Updates to abandoned/outdated pages in reference/ctype/ * Correction to double-byte UTF-8 character which is similar to 'E' * Correction of translation * Updates to abandoned/outdated files and new translations in reference/dir/ * Updates to abandoned/outdated files in reference/mysqli/ * New translation of reference/sockets/functions/socket-atmark.xml * New translation of reference/stream/* * Corrections after QA scripts * Delete reference/stream/versions.xml Arquivo marcado para não tradução. --------- Co-authored-by: LEONARDO LARA RODRIGUES <leonardolara@github.com> Co-authored-by: alfsb <alfsb@users.noreply.github.com>
207 lines
5.4 KiB
XML
207 lines
5.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 6b64170daac5587bee4bb63c0020cb2fbf7f1253 Maintainer: lhsazevedo Status: ready --><!-- CREDITS: amandavale, fabioluciano, lhsazevedo, fernandowobeto -->
|
|
<refentry xml:id="function.array-diff-assoc" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>array_diff_assoc</refname>
|
|
<refpurpose>Computa a diferença entre arrays com checagem adicional de índice</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>array_diff_assoc</methodname>
|
|
<methodparam><type>array</type><parameter>array</parameter></methodparam>
|
|
<methodparam rep="repeat"><type>array</type><parameter>arrays</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Compara <parameter>array</parameter> com <parameter>arrays</parameter> e
|
|
retorna a diferença. Ao contrário de <function>array_diff</function>, as
|
|
chaves dos arrays também são usadas na comparação.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
<term><parameter>array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
O array a ser comparado
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><parameter>arrays</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Arrays para comparar
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Retorna um <type>array</type> contendo todos os valores do
|
|
<parameter>array</parameter> que não estão presentes em qualquer um dos outros arrays.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
&array.changelog.require-only-one;
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<!--
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
&errors.no.unusual.errors;
|
|
</refsect1>
|
|
-->
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemplo de <function>array_diff_assoc</function></title>
|
|
<para>
|
|
Neste exemplo o par <literal>"a" => "verde"</literal>
|
|
está presente em ambos os arrays e por isso não está na saída da
|
|
função. Por outro lado, o par <literal>0 => "vermelho"</literal>
|
|
está na saída porque a chave de <literal>"vermelho"</literal> é
|
|
automaticamente atribuído para <literal>0</literal> no primeiro array,
|
|
enquanto é atribuído para <literal>1</literal> no segundo array já que a
|
|
chave <literal>0</literal> já foi tomada por <literal>amarelo</literal>.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$array1 = array("a" => "verde", "b" => "marrom", "c" => "azul", "vermelho");
|
|
$array2 = array("a" => "verde", "amarelo", "vermelho");
|
|
$result = array_diff_assoc($array1, $array2);
|
|
print_r($result);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[b] => marrom
|
|
[c] => azul
|
|
[0] => vermelho
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Exemplo da função <function>array_diff_assoc</function></title>
|
|
<para>
|
|
Dois valores dos pares <emphasis>chave => valor</emphasis> são
|
|
considerados iguais somente se <literal>(string) $elem1 === (string)
|
|
$elem2 </literal>. Em outras palavras, uma checagem estrita de string é
|
|
feita para que representações de string sejam as mesmas.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$array1 = array(0, 1, 2);
|
|
$array2 = array("00", "01", "2");
|
|
$result = array_diff_assoc($array1, $array2);
|
|
print_r($result);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[0] => 0
|
|
[1] => 1
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<simpara>
|
|
Esta função checa somente uma dimensão de um array n-dimensional. É possível verificar
|
|
dimensões mais profundas usando, por exemplo,
|
|
<literal>array_diff_assoc($array1[0], $array2[0]);</literal>.
|
|
</simpara>
|
|
</note>
|
|
<note>
|
|
<simpara>
|
|
Certifique-se de que os argumentos sejam passados na ordem correta ao comparar arrays
|
|
semelhantes com mais chaves. O novo array deve ser o primeiro array da lista.
|
|
</simpara>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>array_diff</function></member>
|
|
<member><function>array_diff_uassoc</function></member>
|
|
<member><function>array_udiff_assoc</function></member>
|
|
<member><function>array_udiff_uassoc</function></member>
|
|
<member><function>array_intersect</function></member>
|
|
<member><function>array_intersect_assoc</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:"~/.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
|
|
-->
|