array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'collator.construct.php', 1 => 'Collator::__construct', ), 'up' => array ( 0 => 'class.collator.php', 1 => 'Collator', ), 'prev' => array ( 0 => 'collator.compare.php', 1 => 'Collator::compare', ), 'next' => array ( 0 => 'collator.create.php', 1 => 'Collator::create', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/intl/collator/construct.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)
Collator::__construct — collator を作成する
locale
照合規則を使用するロケール。特殊な場合として、
空文字列を渡した場合はデフォルトのロケールの照合規則を使用します。
"root"
を渡した場合は、
» UCA の規則を使用します。
locale
属性は、
各国・各地域のユーザーの期待通りに並べ替えやマッチングを行うために
もっとも重要な属性です。デフォルトの
» UCA
の並び順で正しく ("正しく" とは、その言語を使用する人の期待通りにということです)
処理できるのは、オランダ語やポルトガル語などの一部の言語だけです。
それ以外の場合は、UCA にロケールを指定して
その言語に応じた適切な照合を行えるようにする必要があります。
従って、各ロケールにあわせて正しく設定した collator を使用する必要があります。
ロケールを選択すると、その他の属性の値も適切な物に自動設定されます。
従って、その他の属性については明示的に設定する必要はほとんどありません。
選択したロケールによっては、文字列比較のパフォーマンスやソートキーの長さに違いが出ることがあります。
エラー時には "空の" オブジェクトを返します。何が起こったのかを知るには intl_get_error_code() や intl_get_error_message() を使用します。
例1 Collator::__construct() の例
<?php
$coll = new Collator('en_CA');
?>