Country code conversion

Reply

Join Date: Jul 2006
Posts: 197
Reputation: vssp has a little shameless behaviour in the past 
Solved Threads: 5
vssp vssp is offline Offline
Junior Poster

Country code conversion

 
0
  #1
Jul 3rd, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 494
Reputation: Puckdropper is an unknown quantity at this point 
Solved Threads: 21
Puckdropper Puckdropper is offline Offline
Posting Pro in Training

Re: Country code conversion

 
1
  #2
Jul 3rd, 2006
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.
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,075
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: Country code conversion

 
0
  #3
Jul 3rd, 2006
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
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!
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 197
Reputation: vssp has a little shameless behaviour in the past 
Solved Threads: 5
vssp vssp is offline Offline
Junior Poster

Re: Country code conversion

 
0
  #4
Jul 4th, 2006
Thanks

Sorry I am not give you home work .

vssp
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,075
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: Country code conversion

 
0
  #5
Jul 4th, 2006
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!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC