mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-24 07:02:09 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/pt_BR/trunk@314030 c90b9560-bf6c-de11-be94-00142212c4b1
131 lines
3.1 KiB
XML
131 lines
3.1 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- EN-Revision: n/a Maintainer: felipe Status: ready --><!-- CREDITS: lucasr, narigone -->
|
|
<refentry xml:id="function.array-unique" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>array_unique</refname>
|
|
<refpurpose>Remove o valores duplicados de um array</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>array_unique</methodname>
|
|
<methodparam><type>array</type><parameter>array</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Recebe o argumento <parameter>array</parameter> e retorna um novo array sem valores
|
|
duplicados.
|
|
</para>
|
|
<para>
|
|
Note que as chaves são preservadas. <function>array_unique</function>
|
|
ordena inicialmente os valores como strings mantendo a primeira
|
|
chave encontrada para cada valor, e ignorando as chaves encontradas
|
|
posteriormente. Isso não significa que a chave do primeiro valor
|
|
do <parameter>array</parameter> ainda desordenado será mantido.
|
|
</para>
|
|
<note>
|
|
<simpara>
|
|
Dois elementos são considerados iguais se, e somente se,
|
|
<literal>(string) $elem1 === (string) $elem2</literal>. Em palavras:
|
|
quando a represetação em string é a mesma.
|
|
</simpara>
|
|
<simpara>
|
|
O primeiro será usado.
|
|
</simpara>
|
|
</note>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
O array de entrada.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Retorna o array filtrado.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemplo de <function>array_unique</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$input = array("a" => "verde", "vermelho", "b" => "verde", "azul", "vermelho");
|
|
$result = array_unique($input);
|
|
print_r($result);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen role="php">
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[a] => verde
|
|
[0] => vermelho
|
|
[1] => azul
|
|
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><function>array_unique</function> e tipos</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$input = array(4, "4", "3", 4, 3, "3");
|
|
$result = array_unique($input);
|
|
var_dump($result);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen role="php">
|
|
<![CDATA[
|
|
array(2) {
|
|
[0] => int(4)
|
|
[2] => string(1) "3"
|
|
}
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</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
|
|
-->
|