$locale = "en_US"; $lang_code = get_lang_from_locale($locale); echo $lang_code; // Output: "en"
$locale = "de_DE"; $lang_code = get_lang_from_locale($locale); echo $lang_code; // Output: "de"In this example, the function will return the language code "de" from the given locale string "de_DE". This function is part of the PHP i18n package library, which provides a set of functions to handle internationalization and localization in PHP applications.