Locale::composeLocale

locale_compose

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

Locale::composeLocale -- locale_composeReturns a correctly ordered and delimited locale ID

说明

面向对象风格

public static Locale::composeLocale ( array $subtags ) : string

过程化风格

locale_compose ( array $subtags ) : string

Returns a correctly ordered and delimited locale ID the keys identify the particular locale ID subtags, and the values are the associated subtag values.

参数

subtags

an array containing a list of key-value pairs, where the keys identify the particular locale ID subtags, and the values are the associated subtag values.

Note:

The 'variant' and 'private' subtags can take maximum 15 values whereas 'extlang' can take maximum 3 values.e.g. Variants are allowed with the suffix ranging from 0-14. Hence the keys for the input array can be variant0, variant1, ...,variant14. In the returned locale id, the subtag is ordered by suffix resulting in variant0 followed by variant1 followed by variant2 and so on.

The 'variant', 'private' and 'extlang' multiple values can be specified both as array under specific key (e.g. 'variant') and as multiple numbered keys (e.g. 'variant0', 'variant1', etc.).

返回值

The corresponding locale identifier.

范例

Example #1 locale_compose() example

<?php
$arr 
= array(
    
'language'=>'en' ,
    
'script'  =>'Hans' ,
    
'region'  =>'CN',
    
'variant2'=>'rozaj' ,
    
'variant1'=>'nedis' ,
    
'private1'=>'prv1' ,
    
'private2'=>'prv2'
);
echo 
locale_compose$arr );
?>

Example #2 OO example

<?php
$arr 
= array(
    
'language'=>'en' ,
    
'script'  =>'Hans' ,
    
'region'  =>'CN',
    
'variant2'=>'rozaj' ,
    
'variant1'=>'nedis' ,
    
'private1'=>'prv1' ,
    
'private2'=>'prv2'
);
echo 
Locale::composeLocale$arr );
?>

以上例程会输出:

Locale: en_Hans_CN_nedis_rozaj_x_prv1_prv2

参见

  • locale_parse() - Returns a key-value array of locale ID subtag elements

相关文章
php ibm db2 函数 returns the auto generated id of the last insert query that successfully executed on this connectionphp maxdb 函数 returns the auto generated id used in the last queryphp maxdb 函数 returns the thread id for the current connectionphp ktaglib id3v2 frame returns the size of the frame in bytesphp ktaglib id3v2 frame returns a string representation of the framephp ktaglib id3v2 tag returns an array of id3v2 frames associated with the id3v2 tagphp locale returns a correctly ordered and delimited locale idphp locale returns an appropriately localized display name for language of the inputlocalephp locale returns an appropriately localized display name for the input localephp locale returns an appropriately localized display name for region of the input localephp locale returns an appropriately localized display name for script of the input localephp locale returns an appropriately localized display name for variants of the input localephp locale returns a key value array of locale id subtag elementsphp mongocursor returns the current result s id or its index within the result setphp mongodb driver cursor returns the id for this cursorphp mongodb driver monitoring commandstartedevent returns the command s operation idphp mongodb driver monitoring commandstartedevent returns the command s request idphp mysqlnduhconnection returns the auto generated id used in the last queryphp ktaglib tag returns the album string from a id3 tagphp ktaglib tag returns the year from a id3 tag
关注编程学问公众号