Skip to content

Instantly share code, notes, and snippets.

@ricardobarantini
Last active September 28, 2024 01:26
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'
);
@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