Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regex 1

Status
Not open for further replies.

Extension

Programmer
Nov 3, 2004
311
CA

Hi,

I want to use the IP to Country service from hostip.info and they are "spitting" back the country information in the following structure:

Code:
Country: UNITED STATES (US)
City: Chicago, IL

I only want to keep the country name and acronym, in this case, keep UNITED STATES (US).

I was wondering what Regex I could use to achieve this ?

Thanks.
 
Code:
function returnCountry($input){
 list ($__country) = explode ("\n", $input);
 list ($_country) = explode (":", $__country);
 return trim($_country);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top