downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

iconv> <locale_get_default
Last updated: Fri, 13 Nov 2009

view this page in

locale_set_default

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)

locale_set_defaultデフォルトのロケールを設定する

説明

bool locale_set_default ( string $name )

PHP プログラムのデフォルトのロケールを設定します。 この関数は、setlocale() やシステムロケールには何の影響も及ぼさないことに注意しましょう。

パラメータ

name

新しいロケール名。サポートされるロケールの一覧は » http://demo.icu-project.org/icu-bin/locexp にあります。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。

例1 locale_set_default() の例

ここでは、 locale_set_default() を使用して sort() 関数をローカライズする例を示します。

<?php

// ソートする文字列のリスト
$array = array(
    
'caramelo',
    
'cacto',
    
'caçada'
);

// ロケールを設定します (この場合はポルトガル語)
locale_set_default('pt_PT');

// 設定したロケールを使用して並べ替えます
sort($arraySORT_LOCALE_STRING);

print_r($array);
?>

上の例の出力は以下となります。

Array
(
    [0] => caçada
    [1] => cacto
    [2] => caramelo
)

ロケールを使用しない場合は、PHP は ASCII 文字コードを使用してソートを行います。そのため、 以下のような結果となります (これは間違った結果です)

Array
(
    [0] => cacto
    [1] => caramelo
    [2] => caçada
)

参考

  • locale_get_default() - INTL のグローバル 'default_locale' からデフォルトのロケールを取得する



add a note add a note User Contributed Notes
locale_set_default
There are no user contributed notes for this page.

iconv> <locale_get_default
Last updated: Fri, 13 Nov 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites