mirror of
https://github.com/php/doc-ja.git
synced 2026-03-25 07:32:13 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@302586 c90b9560-bf6c-de11-be94-00142212c4b1
213 lines
5.8 KiB
XML
213 lines
5.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: d5e635d12d50d89660a61a02dde143a7d6296d0b Maintainer: hirokawa Status: ready -->
|
|
<refentry xml:id="function.array-unique" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>array_unique</refname>
|
|
<refpurpose>配列から重複した値を削除する</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>
|
|
<parameter>array</parameter> を入力とし、値に重複のない新規配列を返します。
|
|
</para>
|
|
<para>
|
|
キーは保持されることに注意してください。
|
|
<function>array_unique</function> はまず文字列として値をソートし、
|
|
各値の最初のキーを保持し、2回目以降の全てのキーを無視します。
|
|
これは、ソート前の <parameter>array</parameter>
|
|
で最初の関連する値のキーが保持されるという意味ではありません。
|
|
</para>
|
|
<note>
|
|
<simpara>
|
|
<literal>(string) $elem1 === (string) $elem2</literal>
|
|
の場合のみ二つの要素は等しいとみなされます。
|
|
言い換えると、文字列表現が同じ場合となります。
|
|
</simpara>
|
|
<simpara>
|
|
最初の要素が使用されます。
|
|
</simpara>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
入力の配列。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>sort_flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
オプションの 2 番目のパラメータ <parameter>sort_flags</parameter>
|
|
にこれらの値を使用して、ソートの挙動を変更します。
|
|
</para>
|
|
<para>
|
|
ソート形式のフラグは次のとおりです。
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara><constant>SORT_REGULAR</constant> - 通常の比較
|
|
(型変換をしない) を行います</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_NUMERIC</constant> - 数値として比較します</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_STRING</constant> - 文字列として比較します</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_LOCALE_STRING</constant> -
|
|
現在のロケールにもとづいて文字列として比較します。
|
|
<!--
|
|
FIXME: PHP_6
|
|
PHP 6 より前のバージョンではシステムのロケールを使用します。これは
|
|
<function>setlocale</function> で変更可能です。PHP 6 以降では
|
|
<function>i18n_loc_set_default</function> 関数を使用する必要があります。
|
|
-->
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
処理済の配列を返します。
|
|
</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>5.2.10</entry>
|
|
<entry>
|
|
<parameter>sort_flags</parameter> のデフォルト値を
|
|
SORT_STRING に戻しました。
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>5.2.9</entry>
|
|
<entry>
|
|
オプションの <parameter>sort_flags</parameter> が追加され、
|
|
デフォルトは SORT_REGULAR となりました。5.2.9 より前のバージョンでは、
|
|
この関数は内部的に SORT_STRING によるソートを行っていました。
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>array_unique</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$input = array("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> と型</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>
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<simpara>
|
|
<function>array_unique</function> は、
|
|
多次元配列での使用を想定したものではないことに注意しましょう。
|
|
</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
|
|
-->
|