$URL="http://api.ipinfodb.com/v3/ip-city/?key=tuakey&ip=$ip&format=json";
#####per la citta ip-city##############
#echo"$URL
";
$URL = rawurldecode($URL);
$URL = stripslashes($URL);
// make sure curl is installed
if (function_exists('curl_init')) {
// initialize a new curl resource
$ch = curl_init();
// set the url to fetch
curl_setopt($ch, CURLOPT_URL, $URL);
// don't give me the headers just the content
curl_setopt($ch, CURLOPT_HEADER, 0);
// return the value instead of printing the response to browser
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// use a user agent to mimic a browser
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');
$content = curl_exec($ch);
#echo $content;
// remember to always close the session and free all resources
curl_close($ch);
} else {
// curl library is not installed so we better use something else
}
#####################################################################
$json=$content;
$obj = json_decode($json);
$regionName=$obj->{'regionName'}; // 12345
$cityName=$obj->{'cityName'}; // 12345
echo"#$regionName#";