Locale::lookup

locale_lookup

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

Locale::lookup -- locale_lookupSearches the language tag list for the best match to the language

说明

面向对象风格

public static Locale::lookup ( array $langtag , string $locale [, bool $canonicalize = FALSE [, string $default ]] ) : string

过程化风格

locale_lookup ( array $langtag , string $locale [, bool $canonicalize = FALSE [, string $default ]] ) : string

Searches the items in langtag for the best match to the language range specified in locale according to RFC 4647's lookup algorithm.

参数

langtag

An array containing a list of language tags to compare to locale. Maximum 100 items allowed.

locale

The locale to use as the language range when matching.

canonicalize

If true, the arguments will be converted to canonical form before matching.

default

The locale to use if no match is found.

返回值

The closest matching language tag or default value.

范例

Example #1 locale_lookup() example

<?php
$arr 
= array(
    
'de-DEVA',
    
'de-DE-1996',
    
'de',
    
'de-De'
);
echo 
locale_lookup($arr'de-DE-1996-x-prv1-prv2'true'en_US');
?>

Example #2 OO example

<?php
$arr 
= array(
    
'de-DEVA',
    
'de-DE-1996',
    
'de',
    
'de-De'
);
echo 
Locale::lookup($arr'de-DE-1996-x-prv1-prv2'true'en_US');
?>

以上例程会输出:

de_de_1996

参见

相关文章
php domdocument searches for all elements with given local tag namephp domdocument searches for all elements with given tag name in specified namespacephp hash 函数 return a list of registered hashing algorithms suitable for hash hmacphp 字符串 函数 query language and locale informationphp odbc 函数 get the list of table names stored in a specific data sourcephp pspell 函数 determine whether to save a replacement pairs list along with the wordlistphp rpm reader 函数 retrieves a header tag from an rpm filephp sodium 函数 compute a tag for the messagephp xmlwriter 函数 write full dtd entity tagphp hyperwave api 函数 returns a list of all logged in usersphp locale tries to find out best available locale based on http accept language headerphp locale checks if a language tag filter matches with localephp locale returns an appropriately localized display name for language of the inputlocalephp locale returns an appropriately localized display name for the input localephp locale gets the primary language for the input localephp locale searches the language tag list for the best match to the languagephp mysqli returns a list of errors from the last command executedphp sdo das relational 函数 executes an sql query passed as a prepared statement with a list of values to substitute for placeholders and return the results as a normalised data graphphp spldoublylinkedlist check whether the doubly linked list contains more nodesphp swfgradient adds an entry to the gradient list
关注编程学问公众号