$locale = 'en_US'; $components = Locale::requireComponents($locale, array( Locale::LANGUAGE, Locale::REGION )); print_r($components);
Array ( [language] => en [region] => US )
$locale = 'zh_Hans_CN@collation=stroke'; $components = Locale::requireComponents($locale, array( Locale::SCRIPT, Locale::VARIANT )); print_r($components);
Array ( [script] => Hans [variant] => collation=stroke )In this example, the `requireComponents` method is used to extract the script and variant components of the locale "zh_Hans_CN@collation=stroke". The resulting array contains the corresponding values "Hans" and "collation=stroke". Package library: The `requireComponents` method is part of the PHP Internationalization (Intl) extension.