Skip to content

Instantly share code, notes, and snippets.

@ricardobarantini
Last active December 12, 2023 19:04
Show Gist options
  • Save ricardobarantini/5665214 to your computer and use it in GitHub Desktop.
Save ricardobarantini/5665214 to your computer and use it in GitHub Desktop.
Array com nome e siglas de estados Brasileiros para select do Codeigniter
$estadosBrasileiros = array(
'AC'=>'Acre',
'AL'=>'Alagoas',
'AP'=>'Amapá',
'AM'=>'Amazonas',
'BA'=>'Bahia',
'CE'=>'Ceará',
'DF'=>'Distrito Federal',
'ES'=>'Espírito Santo',
'GO'=>'Goiás',
'MA'=>'Maranhão',
'MT'=>'Mato Grosso',
'MS'=>'Mato Grosso do Sul',
'MG'=>'Minas Gerais',
'PA'=>'Pará',
'PB'=>'Paraíba',
'PR'=>'Paraná',
'PE'=>'Pernambuco',
'PI'=>'Piauí',
'RJ'=>'Rio de Janeiro',
'RN'=>'Rio Grande do Norte',
'RS'=>'Rio Grande do Sul',
'RO'=>'Rondônia',
'RR'=>'Roraima',
'SC'=>'Santa Catarina',
'SP'=>'São Paulo',
'SE'=>'Sergipe',
'TO'=>'Tocantins'
);
@AmauriBlanco
Copy link

Mais uma lista para ajudar.

estados(): EstadoInterface[]{
return [
{ nome: 'Acre', sigla: 'AC' },
{ nome: 'Alagoas', sigla: 'AL' },
{ nome: 'Amapá', sigla: 'AP' },
{ nome: 'Amazonas', sigla: 'AM' },
{ nome: 'Bahia', sigla: 'BA' },
{ nome: 'Ceará', sigla: 'CE' },
{ nome: 'Distrito Federal', sigla: 'DF' },
{ nome: 'Espírito Santo', sigla: 'ES' },
{ nome: 'Goiás', sigla: 'GO' },
{ nome: 'Maranhão', sigla: 'MA' },
{ nome: 'Mato Grosso', sigla: 'MT' },
{ nome: 'Mato Grosso do Sul', sigla: 'MS' },
{ nome: 'Minas Gerais', sigla: 'MG' },
{ nome: 'Pará', sigla: 'PA' },
{ nome: 'Paraíba', sigla: 'PB' },
{ nome: 'Paraná', sigla: 'PR' },
{ nome: 'Pernambuco', sigla: 'PE' },
{ nome: 'Piauí', sigla: 'PI' },
{ nome: 'Rio de Janeiro', sigla: 'RJ' },
{ nome: 'Rio Grande do Norte', sigla: 'RN' },
{ nome: 'Rio Grande do Sul', sigla: 'RS' },
{ nome: 'Rondônia', sigla: 'RO' },
{ nome: 'Roraima', sigla: 'RR' },
{ nome: 'Santa Catarina', sigla: 'SC' },
{ nome: 'São Paulo', sigla: 'SP' },
{ nome: 'Sergipe', sigla: 'SE' },
{ nome: 'Tocantins', sigla: 'TO' },
];

@rennanmserenza
Copy link

Estados com id separados em ordem alfabética

estados: [
		{
			id: 12,
			nome: 'Acre',
			sigla: 'AC',
		},
		{
			id: 27,
			nome: 'Alagoas',
			sigla: 'AL',
		},
		{
			id: 16,
			nome: 'Amapá',
			sigla: 'AP',
		},
		{
			id: 13,
			nome: 'Amazonas',
			sigla: 'AM',
		},
		{
			id: 29,
			nome: 'Bahia',
			sigla: 'BA',
		},
		{
			id: 23,
			nome: 'Ceará',
			sigla: 'CE',
		},
		{
			id: 53,
			nome: 'Distrito Federal',
			sigla: 'DF',
		},
		{
			id: 32,
			nome: 'Espírito Santo',
			sigla: 'ES',
		},
		{
			id: 52,
			nome: 'Goiás',
			sigla: 'GO',
		},
		{
			id: 21,
			nome: 'Maranhão',
			sigla: 'MA',
		},
		{
			id: 51,
			nome: 'Mato Grosso',
			sigla: 'MT',
		},
		{
			id: 50,
			nome: 'Mato Grosso do Sul',
			sigla: 'MS',
		},
		{
			id: 31,
			nome: 'Minas Gerais',
			sigla: 'MG',
		},
		{
			id: 15,
			nome: 'Pará',
			sigla: 'PA',
		},
		{
			id: 25,
			nome: 'Paraíba',
			sigla: 'PB',
		},
		{
			id: 41,
			nome: 'Paraná',
			sigla: 'PR',
		},
		{
			id: 26,
			nome: 'Pernambuco',
			sigla: 'PE',
		},
		{
			id: 22,
			nome: 'Piauí',
			sigla: 'PI',
		},
		{
			id: 33,
			nome: 'Rio de Janeiro',
			sigla: 'RJ',
		},
		{
			id: 24,
			nome: 'Rio Grande do Norte',
			sigla: 'RN',
		},
		{
			id: 43,
			nome: 'Rio Grande do Sul',
			sigla: 'RS',
		},
		{
			id: 11,
			nome: 'Rondônia',
			sigla: 'RO',
		},
		{
			id: 14,
			nome: 'Roraima',
			sigla: 'RR',
		},
		{
			id: 42,
			nome: 'Santa Catarina',
			sigla: 'SC',
		},
		{
			id: 35,
			nome: 'São Paulo',
			sigla: 'SP',
		},
		{
			id: 28,
			nome: 'Sergipe',
			sigla: 'SE',
		},
		{
			id: 17,
			nome: 'Tocantins',
			sigla: 'TO',
		},
	],

@dannex3
Copy link

dannex3 commented Mar 24, 2023

Como obj em Js com as siglas na key:
const statesBr = {
AC: 'Acre',
AL: 'Alagoas',
AP: 'Amapá',
AM: 'Amazonas',
BA: 'Bahia',
CE: 'Ceará',
DF: 'Distrito Federal',
ES: 'Espírito Santo',
GO: 'Goiás',
MA: 'Maranhão',
MT: 'Mato Grosso',
MS: 'Mato Grosso do Sul',
MG: 'Minas Gerais',
PA: 'Pará',
PB: 'Paraíba',
PR: 'Paraná',
PE: 'Pernambuco',
PI: 'Piauí',
RJ: 'Rio de Janeiro',
RN: 'Rio Grande do Norte',
RS: 'Rio Grande do Sul',
RO: 'Rondônia',
RR: 'Roraima',
SC: 'Santa Catarina',
SP: 'São Paulo',
SE: 'Sergipe',
TO: 'Tocantins'
}

@mateusSousaSilva
Copy link

"UF": [
"AC",
"AL",
"AP",
"AM",
"BA",
"CE",
"DF",
"ES",
"GO",
"MA",
"MT",
"MS",
"MG",
"PA",
"PB",
"PR",
"PE",
"PI",
"RJ",
"RN",
"RS",
"RO",
"RR",
"SC",
"SP",
"SE",
"TO"
],

@GuiDeto
Copy link

GuiDeto commented Jul 20, 2023

$dddsPorEstado = [
"AC" => ["68"],
"AL" => ["82"],
"AM" => ["92", "97"],
"AP" => ["96"],
"BA" => ["71", "73", "74", "75", "77"],
"CE" => ["85", "88"],
"DF" => ["61"],
"ES" => ["27", "28"],
"GO" => ["62", "64"],
"MA" => ["98", "99"],
"MG" => ["31", "32", "33", "34", "35", "37", "38"],
"MS" => ["67"],
"MT" => ["65", "66"],
"PA" => ["91", "93", "94"],
"PB" => ["83"],
"PE" => ["81", "87"],
"PI" => ["86", "89"],
"PR" => ["41", "42", "43", "44", "45", "46"],
"RJ" => ["21", "22", "24"],
"RN" => ["84"],
"RO" => ["69"],
"RR" => ["95"],
"RS" => ["51", "53", "54", "55"],
"SC" => ["47", "48", "49"],
"SE" => ["79"],
"SP" => ["11", "12", "13", "14", "15", "16", "17", "18", "19"],
"TO" => ["63"]
];

@matheusgomesbs
Copy link

Enum em TypeScript com Códigos das UF's

export enum EnumUFCode {
  AC = 12,
  AL = 27,
  AM = 13,
  AP = 16,
  BA = 29,
  CE = 23,
  DF = 53,
  ES = 32,
  GO = 52,
  MA = 21,
  MG = 31,
  MS = 50,
  MT = 51,
  PA = 15,
  PB = 25,
  PE = 26,
  PI = 22,
  PR = 41,
  RJ = 33,
  RN = 24,
  RO = 11,
  RR = 14,
  RS = 43,
  SC = 42,
  SE = 28,
  SP = 35,
  TO = 17,
}

@marcelosb
Copy link

Enum em PHP:

enum BrazilianStatesEnum: int
{
    case AC = 12;
    case AL = 27;
    case AP = 16;
    case AM = 13;
    case BA = 29;
    case CE = 23;
    case DF = 53;
    case ES = 32;
    case GO = 52;
    case MA = 21;
    case MT = 51;
    case MS = 50;
    case MG = 31;
    case PA = 15;
    case PB = 25;
    case PR = 41;
    case PE = 26;
    case PI = 22;
    case RJ = 33;
    case RN = 24;
    case RS = 43;
    case RO = 11;
    case RR = 14;
    case SC = 42;
    case SP = 35;
    case SE = 28;
    case TO = 17;

    public function getName(): string
    {
        return match($this) {
            static::AC => 'Acre',
            static::AL => 'Alagoas',
            static::AP => 'Amapá',
            static::AM => 'Amazonas',
            static::BA => 'Bahia',
            static::CE => 'Ceará',
            static::DF => 'Distrito Federal',
            static::ES => 'Espírito Santo',
            static::GO => 'Goiás',
            static::MA => 'Maranhão',
            static::MT => 'Mato Grosso',
            static::MS => 'Mato Grosso do Sul',
            static::MG => 'Minas Gerais',
            static::PA => 'Pará',
            static::PB => 'Paraíba',
            static::PR => 'Paraná',
            static::PE => 'Pernambuco',
            static::PI => 'Piauí',
            static::RJ => 'Rio de Janeiro',
            static::RN => 'Rio Grande do Norte',
            static::RS => 'Rio Grande do Sul',
            static::RO => 'Rondônia',
            static::RR => 'Roraima',
            static::SC => 'Santa Catarina',
            static::SP => 'São Paulo',
            static::SE => 'Sergipe',
            static::TO => 'Tocantins',
        };
    }

    public function getRegion(): string
    {
        return match($this) {
            static::AC => 'Norte',
            static::AL => 'Nordeste',
            static::AP => 'Norte',
            static::AM => 'Norte',
            static::BA => 'Nordeste',
            static::CE => 'Nordeste',
            static::DF => 'Centro-Oeste',
            static::ES => 'Sudeste',
            static::GO => 'Centro-Oeste',
            static::MA => 'Nordeste',
            static::MT => 'Centro-Oeste',
            static::MS => 'Centro-Oeste',
            static::MG => 'Sudeste',
            static::PA => 'Norte',
            static::PB => 'Nordeste',
            static::PR => 'Sul',
            static::PE => 'Nordeste',
            static::PI => 'Nordeste',
            static::RJ => 'Sudeste',
            static::RN => 'Nordeste',
            static::RS => 'Sul',
            static::RO => 'Norte',
            static::RR => 'Norte',
            static::SC => 'Sul',
            static::SP => 'Sudeste',
            static::SE => 'Nordeste',
            static::TO => 'Norte',
        };
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment