| | |
Country code conversion
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2006
Posts: 197
Reputation:
Solved Threads: 5
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
Thanks
vssp
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
Thanks
vssp
•
•
Join Date: Jul 2004
Posts: 494
Reputation:
Solved Threads: 21
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.
Why not just do an UPDATE in SQL. That's not PHP, but it's the easiest way to do it.
www.uncreativelabs.net
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
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
) however its a very simple task.
Heres the link to php documentation on the array notation/syntax:
http://php.net/manual/en/language.types.array.php
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

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
) however its a very simple task.Heres the link to php documentation on the array notation/syntax:
http://php.net/manual/en/language.types.array.php
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
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
![]() |
Similar Threads
- code conversion from C++ to delphi (Pascal and Delphi)
- IP-to-Country converter (php script) (PHP)
- code conversion from c\c++ to java (C++)
Other Threads in the PHP Forum
- Previous Thread: How to mail a report automatically from web.
- Next Thread: Help With Messages in Mysql Stop Overwriting
| Thread Tools | Search this Thread |
apache api array beginner beneath binary broadband broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date display dynamic echo email error fcc file files folder form forms freelancing function functions google href htaccess html image include incode insert integration ip javascript joomla limit link login mail match menu method mlm mod_rewrite multiple mysql oop pageing pagerank paypal pdf php problem query radio random recursion recursiveloop remote script search server sessions sms smtp soap source space sql strip_tags subversion support! survey syntax system table template tutorial undefined update upload url validator variable video virus web window.onbeforeunload=closeme; youtube






