mirror of
https://github.com/php/doc-pl.git
synced 2026-03-24 07:02:07 +01:00
211 lines
5.4 KiB
XML
211 lines
5.4 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!-- EN-Revision: 651fad6c6677036edd2871bb78199e17586a3acd Maintainer: joeaccord Status: ready -->
|
|
<!-- $Revision$ -->
|
|
<!-- CREDITS: leszek, sobak, grzesiek -->
|
|
<refentry xml:id="function.array-unique" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>array_unique</refname>
|
|
<refpurpose>Usuwa duplikaty wartości z tablicy</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>flags</parameter><initializer><constant>SORT_STRING</constant></initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Pobiera wejściową tablicę <parameter>array</parameter> i zwraca nową tablicę
|
|
bez duplikatów wartości.
|
|
</para>
|
|
<para>
|
|
Zauważ, że klucze są zachowywane. Jeśli wiele elementów porównywanych jest
|
|
równych w ramach danego parametru <parameter>flags</parameter>, wówczas klucz
|
|
i wartość pierwszego równego elementu zostaną zachowane.
|
|
</para>
|
|
<note>
|
|
<simpara>
|
|
Dwa elementy tablicy są uważane za równe wtedy i tylko wtedy jeśli
|
|
<literal>(string) $elem1 === (string) $elem2</literal>, to znaczy, gdy
|
|
reprezentacje jako ciąg znaków są takie same, to użyty będzie pierwszy element.
|
|
</simpara>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Tablica wejściowa.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Drugi, opcjonalny parametr <parameter>flags</parameter>
|
|
może być użyty do zmiany zachowania podczas porównywania za pomocą następujących wartości:
|
|
</para>
|
|
<para>
|
|
Flagi typu porównywania:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara><constant>SORT_REGULAR</constant> - porównuje pozycje normalnie
|
|
(nie zmienia typów)</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_NUMERIC</constant> - porównuje pozycje numerycznie</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_STRING</constant> - porównuje pozycje jako łańcuchy znaków</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_LOCALE_STRING</constant> - porównuje pozycje jako łańcuchy znaków,
|
|
w uwzględniając bieżące kodowanie znaków.
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Zwraca posortowaną tablicę.
|
|
</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>
|
|
Jeśli parametr <parameter>flags</parameter> ma wartość <constant>SORT_STRING</constant>,
|
|
wcześniej tablica <parameter>array</parameter> została skopiowana i nieunikalne
|
|
elementy zostały usunięte (bez późniejszego pakowania tablicy), ale teraz budowana
|
|
jest nowa tablica poprzez dodanie unikalnych elementów. Może to skutkować
|
|
różnymi indeksami liczbowymi.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Przykład użycia <function>array_unique</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$input = ["a" => "green", "red", "b" => "green", "blue", "red"];
|
|
$result = array_unique ($input);
|
|
print_r($result);
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen role="php">
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[a] => green
|
|
[0] => red
|
|
[1] => blue
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><function>array_unique</function> i typy</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$input = [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>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<simpara>
|
|
Zauważ, że funkcja <function>array_unique</function> nie jest przeznaczona do
|
|
pracy na wielowymiarowych tablicach.
|
|
</simpara>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>array_count_values</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
|
|
-->
|