Skip navigation

I recently had a code problem I didn’t believe I would ever solve. I’m not the most agile programmer so a problem such as the following tends to intimidate me. However, with some help from a friend and PHP’s built in string functions, I came up with a solution.

Problem: Our dies had location codes based on an alphanumeric system such as “AA13”. After getting to “ZZ14”, we decided it was long past time to switch to a numeric only system. I needed to transform the old locations to reflect corresponding numbers (A = 1, B = 2, AA = 27, etc). Easy enough in text, but seemingly daunting in code.

Solution: Using an array of the alphabet, some string functions and some friendly advice, I came up with this:

Looking back, the solution seems much easier than I thought it would be. I suppose that’s how it goes.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: