<?php
$ip = $_SERVER['REMOTE_ADDR'];
$dataArray = json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
echo "<pre>";
print_r($dataArray);
echo "You are from: ".$dataArray->geoplugin_countryName;
?>
Output :
$ip = $_SERVER['REMOTE_ADDR'];
$dataArray = json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
echo "<pre>";
print_r($dataArray);
echo "You are from: ".$dataArray->geoplugin_countryName;
?>
Output :
stdClass Object ( [geoplugin_request] => 27.109.6.218 [geoplugin_status] => 206 [geoplugin_city] => [geoplugin_region] => Jammu and Kashmīr [geoplugin_areaCode] => 0 [geoplugin_dmaCode] => 0 [geoplugin_countryCode] => IN [geoplugin_countryName] => India [geoplugin_continentCode] => AS [geoplugin_latitude] => 33.8042 [geoplugin_longitude] => 74.2583 [geoplugin_regionCode] => 12 [geoplugin_regionName] => Jammu and Kashmīr [geoplugin_currencyCode] => INR [geoplugin_currencySymbol] => ₨ [geoplugin_currencySymbol_UTF8] => ₨ [geoplugin_currencyConverter] => 64.1175 ) You are from: India
No comments:
Post a Comment