The Location Lists helper is useful when dealing with countries or states/provinces.
Countries
Loading the Helper
$ch = Loader::helper('lists/countries');
Methods
$countries = $ch->getCountries()
Returns an array of countries. The two-digit ISO country code is the key of each item in the array, with the full country name as its value.
$countries = $ch->getCountries(); print $countries['US'];
$countryName = $ch->getCountryName($index)
Get a country full name given its index.
print $ch->getCountryName('UK');
States/Provinces
Loading the Helper
$sh = Loader::helper('lists/states_provinces');
Methods
$sh->getStateProvinceName($stateProvince, $country)
Gets the full name of a state/province given its abbreviation $stateProvince, and the $country abbreviation.
$sh->getStateProvinceArray($country)
Gets the array of state/provinces for a given $country abbreviation. Sorts in alphabetical order.
$sh->getAll()
Returns the full associate array of all states/provinces.
Loading Conversation