mirror of
https://github.com/php/doc-es.git
synced 2026-03-24 15:32:36 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@349887 c90b9560-bf6c-de11-be94-00142212c4b1
224 lines
5.9 KiB
XML
224 lines
5.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: d8d97da74f7e3495d66b09c7a8805aede75c4cfb Maintainer: seros Status: ready -->
|
|
<!-- Reviewed: no Maintainer: andresdzphp -->
|
|
<refentry xml:id="function.array-unique" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>array_unique</refname>
|
|
<refpurpose>Elimina valores duplicados de un array</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>array_unique</methodname>
|
|
<methodparam><type>array</type><parameter>array</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>sort_flags</parameter><initializer>SORT_STRING</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Toma un <parameter>array</parameter> y devuelve un nuevo array
|
|
sin valores duplicados.
|
|
</para>
|
|
<para>
|
|
Tenga en cuenta que las claves se conservan. Si múltiples elementos se comparan
|
|
bajo el parámetro <parameter>sort_flags</parameter>, entonces la clave y el valor del primer
|
|
elemento igual se conservarán.
|
|
</para>
|
|
<note>
|
|
<simpara>
|
|
Dos elementos son considerados iguales solo si
|
|
<literal>(string) $elem1 === (string) $elem2</literal>, es decir,
|
|
cuando la representación en formato de string sea la misma, se usará el primer elemento.
|
|
</simpara>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
El array de entrada.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>sort_flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
El segundo parámetro opcional <parameter>sort_flags</parameter>
|
|
se puede utilizar para modificar el tipo de orden usando estos valores:
|
|
</para>
|
|
<para>
|
|
Indicadores de tipos de orden:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara><constant>SORT_REGULAR</constant> - compara ítems normalmente
|
|
(no cambia los tipos)</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_NUMERIC</constant> - compara ítems numéricamente</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_STRING</constant> - compara ítems como strings</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_LOCALE_STRING</constant> - compara ítems como
|
|
strings, basados en la configuración regional en uso.
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Devuelve el array filtrado.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>7.2.0</entry>
|
|
<entry>
|
|
Si el parámetro <parameter>sort_flags</parameter> es <constant>SORT_STRING</constant>,
|
|
el <parameter>array</parameter> anterior ha sido copiado y se han eliminado
|
|
los elementos no únicos (sin empaquetar el array posteriormente), pero
|
|
ahora se construye un nuevo array añadiendo los elementos únicos. Esto puede
|
|
dar lugar a diferentes índices numéricos.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>5.2.10</entry>
|
|
<entry>
|
|
Se volvió a cambiar el valor predeterminado de <parameter>sort_flags</parameter> a
|
|
<constant>SORT_STRING</constant>.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>5.2.9</entry>
|
|
<entry>
|
|
Se añadió el parámetro opcional <parameter>sort_flags</parameter> con el
|
|
valor predeterminado <constant>SORT_REGULAR</constant>. Antes de 5.2.9, esta función se usaba para ordenar
|
|
el array con <constant>SORT_STRING</constant> internamente.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <function>array_unique</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$entrada = array("a" => "verde", "rojo", "b" => "verde", "azul", "rojo");
|
|
$resultado = array_unique($entrada);
|
|
print_r($resultado);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen role="php">
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[a] => verde
|
|
[0] => rojo
|
|
[1] => azul
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><function>array_unique</function> y tipos</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$entrada = array(4, "4", "3", 4, 3, "3");
|
|
$resultado = array_unique($entrada);
|
|
var_dump($resultado);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen role="php">
|
|
<![CDATA[
|
|
array(2) {
|
|
[0] => int(4)
|
|
[2] => string(1) "3"
|
|
}
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>array_count_values</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<simpara>
|
|
Observe que <function>array_unique</function> no está pensado
|
|
para que trabaje con arrays multidimensionales.
|
|
</simpara>
|
|
</note>
|
|
</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
|
|
-->
|