Right now In my country database county code vlaues are stored in 3 digits.
So we need to convert the country code three digite to two digit

Please write a php function in an independent php file that will contain an array that will map the current 3 letter country codes in the countries_master.value to 2 letter ISO standard codes in uppercase


Sounds kinda like a homework assignment...

Why not just do an UPDATE in SQL. That's not PHP, but it's the easiest way to do it.

lol.. yes, it does sound like a homework assignment.. :)

Like Puckdropper said, its better to update the SQL rather than PHP. If you're set on PHP (I dont want to do your homework for you :P) however its a very simple task.

Heres the link to php documentation on the array notation/syntax:

You can use the array notation, or array functions (http://php.net/array) to create an array.

Your array should be a simple 1 dimensional array (each value has a single key) that links either:

1) The primary key of countries_master.value with the corresponding 2 digit ISO country code, or

2) The 3 Digit country code field in countries_master.value with the corresponding 2 Digit ISO country code

Knowing the key in an array means you can extract the corresponding value using $array[$key];
So if your array has the 3 digit county codes as index, then $array[$countycode3digits] should retrieve the 2 digit country code value.

It's good practice to first check if the key exists before trying to retieve an array value using the key.
The function to check if a key exists in an array can be found in the array function list: http://php.net/array


Sorry I am not give you home work .