Get state list of a country In drupal 8 we can get country list using following code.

$countries = \Drupal::service('country_manager')-&gt;getList();


But how can I programatically get the list of state of each country?
Drupal core only keeps a record of countries, not all the states/administrative areas within each country.

However the CommerceGuys addressing library has that functionality. Example from their readme:

use CommerceGuys\Addressing\Subdivision\SubdivisionRepository;

$subdivisionRepository = new SubdivisionRepository();

// Get the subdivisions for Brazil.
$states = $subdivisionRepository-&gt;getAll(['BR']);
foreach ($states as $state) {
    $municipalities = $state-&gt;getChildren();
}


If need to get list of states as indexed array use the function 'getList()':

$states = $subdivisionRepository-&gt;getList(['BR']);


Then if you print the $states, you will get:

Array
(
    [AC] =&gt; Acre
    [AL] =&gt; Alagoas
    [AP] =&gt; AmapÃ¡
    [AM] =&gt; Amazonas
    [BA] =&gt; Bahia
    [CE] =&gt; CearÃ¡
    [DF] =&gt; Distrito Federal
    [ES] =&gt; EspÃ­rito Santo
    [GO] =&gt; GoiÃ¡s
    [MA] =&gt; MaranhÃ£o
    [MT] =&gt; Mato Grosso
    [MS] =&gt; Mato Grosso do Sul
    [MG] =&gt; Minas Gerais
    [PA] =&gt; ParÃ¡
    [PB] =&gt; ParaÃ­ba
    [PR] =&gt; ParanÃ¡
    [PE] =&gt; Pernambuco
    [PI] =&gt; PiauÃ­
    [RJ] =&gt; Rio de Janeiro
    [RN] =&gt; Rio Grande do Norte
    [RS] =&gt; Rio Grande do Sul
    [RO] =&gt; RondÃ´nia
    [RR] =&gt; Roraima
    [SC] =&gt; Santa Catarina
    [SP] =&gt; SÃ£o Paulo
    [SE] =&gt; Sergipe
    [TO] =&gt; Tocantins
)