Created
October 10, 2017 00:19
-
-
Save DASPRiD/cd5c361f34c2828282a7025d96cfe7b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function getCountryOptions(string $locale) : array | |
{ | |
$resourceBundle = ResourceBundle::create($locale, 'ICUDATA-region'); | |
$options = []; | |
foreach ($resourceBundle['Countries'] as $countryCode => $label) { | |
if (!preg_match('(^[A-Z]{2}$)', $countryCode) || 'ZZ' === $countryCode) { | |
continue; | |
} | |
$options[$countryCode] = $label; | |
} | |
$collator = new Collator($locale); | |
$collator->asort($options); | |
return $options; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment