Get Country currency code by user IP address in php

$ip=$_SERVER[‘REMOTE_ADDR’];
$countrycode = “http://www.geoplugin.net/json.gp?ip=$ip”;
$ip_data = @json_decode(file_get_contents(“http://www.geoplugin.net/json.gp?ip=”.$ip));

if($ip_data && $ip_data->geoplugin_countryName != null){
$result[‘geoplugin_countryName’] = $ip_data->geoplugin_countryName;
$result[‘geoplugin_currencyCode’] = $ip_data->geoplugin_currencyCode;
}

echo $result[‘geoplugin_currencyCode’];

Advertisements
Posted in PHP

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