I am working through a situation utilizing php to perform a task. I have been reading a php book and it gives examples of doing separate things, but I think I need to combine a few of them to accomplish my goal. That's where I get confused.
My situation: I have 50 websites with the state name in the domain. For example:
*Note #1: they will all use the same naming style, (statename)widgetsonline.com
*Notes #2: I will not
be using a mysql database.
Mission: To extract the state from the domain, run it through some type of php command to look for the state name and to output the associated abbreviation for the state.
In my studying, it gives an example of doing multidimensional arrays and I am guessing here, but my thoughts on applying it for my mission are:
$States = array (
'state' => 'alabama',
'abbrev' => 'AL',
'state' => 'alaska',
'abbrev' => 'AK',
and so on down the line
Then, my thinking was that I somehow get the state name extracted from the domain, put that in a variable, run it through a loop, and once it finds the state, to have an if then statement or a for each statement that gets the abbreviation and then to put that in another variable so I may use it on my web page, then breakout of loop once the condition is met, so it doesn't run a continuous loop.
I might be making this very difficult for myself, but I am green when it comes to using php.
I'd appreciate any insight on this and welcome suggestions.
Thanks in advance,