php8.5
Home/ Manual/ intl / locale/ Locale::getPrimaryLanguage

Locale::getPrimaryLanguage

PHP function Edit on GitHub ✎

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

Gets the primary language for the input locale

Description

Oop

Locale::getPrimaryLanguage(string $locale): string|null

Procedural

locale_get_primary_language(string $locale): string|null

Gets the primary language for the input locale

Parameters

locale

The locale to extract the primary language code from

Return Values

The language code associated with the language.

Return

Examples

locale_get_primary_language() example

php
<?php
echo locale_get_primary_language('zh-Hant');
?>

OO example

php
<?php
echo Locale::getPrimaryLanguage('zh-Hant');
?>

The above example will output:

output
zh

See Also

Source: reference/intl/locale/get-primary-language.xml · from the official PHP manual (php/doc-en)