
US State Names and Abbreviations as PHP Arrays - paultela
https://gist.github.com/maxrice/2776900
======
vlucas
I made the website [http://devdata.io](http://devdata.io) for this exact
reason. You can get an array/list/object of US state names and abbreviations
(and lots of other datasets) in any language supported (currently JavaScript,
PHP, Python, Ruby, C#, and Lua).

~~~
ashmud
Suggestions, based on what we also have/use.

Datasets: Languages (human), SMS Carriers

Language: SQL

------
sjs382
[https://gist.github.com/maxrice/2776900#gistcomment-1200768](https://gist.github.com/maxrice/2776900#gistcomment-1200768)

"Here is the list without Delaware" almost made me spit-take.

~~~
mahouse
Not from the US, what's the joke?

~~~
ashmud
Possibilities:

N-1/+1 joke, since Delaware was the first (by date of ratification) state.

Discussion around incomplete sets (do you include "military" states or other
non-"50 state" territories?).

Ad hominem attack on removed entity (claiming entity is unimportant).

------
pavel_lishin
Completely lost it at

    
    
        <?php
        $THE_UNITED_STATES  = file_get_contents('states_temp.php');
        eval($THE_UNITED_STATES);
        ?>
    
    

_temp.php, evals, temporary variable names... I'm getting flashbacks.

~~~
krapp
file_get_contents should make an http request to its own server for maximum
awesomeness...

assuming the php file just echoes its own source code,which is entirely
doable.

------
csixty4
[http://statetable.com](http://statetable.com) will give you datasets with US
states and/or Canadian provinces, current and/or historical, with or without
DC, with or without minor territories & posessions, and with or without
military addresses.

Data can be exported in CSV, a PHP array, or a whole mess of MySQL commands to
build a table.

It's also open source if you just want the source data:
[https://github.com/daveross/statetable-
com/blob/master/state...](https://github.com/daveross/statetable-
com/blob/master/state.csv)

------
jetskindo
I'll gladly admit that I didn't get it.

------
krapp
I'm surprised PHP doesn't already have US_state_name_to_abbreviation() and
US_state_abbreviation_to_name() baked in already. This is a language that
supports[0] Swatch Internet time[1]. Literally, a "time" format made up as a
gimmick to advertise one specific brand of wristwatch from the late 1990s.

I hope someone on Hacker News who contributes to the PHP core can attempt to
correct this discrepancy.

[0][http://www.php.net/manual/en/function.idate.php](http://www.php.net/manual/en/function.idate.php)

[1][https://en.wikipedia.org/wiki/Swatch_Internet_Time](https://en.wikipedia.org/wiki/Swatch_Internet_Time)

~~~
JshWright
I suspect it would be US_state_name_to_abbreviation() and USStateAbbr2Name()
in order to meet PHP's consistency requirements.

~~~
wdmeldon
When I developed in PHP, I could never understand why they didn't just reach a
compromise that made everyone happy. Like uS_state_nameToAbbreviation() and
uSStateAbbr_to_name()

I call it camel_Snake.

~~~
krylon
Great, now I have tea all over my desk.

Although it was totally worth it. ;-)

------
eridal
Haha I love when spontaneously some joke takes off, even if the joke doesn't
make much sense

;)

------
toxican
That went from "Oh cool, I'll bookmark that" to "hey waaait a minute" real
quick.

