$locale = getLocale(); echo $locale; // outputs "en_US.UTF-8"
$locale = getLocale(); list($language) = explode('_', $locale); echo $language; // outputs "en"This example demonstrates how to extract the language portion of the locale setting using the explode function. Package Library: The getLocale function is part of the PHP Intl (Internationalization) extension, which provides support for various internationalization features such as formatting and parsing numbers, dates, times, currencies, and messages. This extension is included in most PHP distributions and can be enabled by uncommenting the "extension=intl" line in your php.ini file.