- file_get_contents: documentation ( source)
- json_decode: documentation ( source)
<?php
$userip = $_SERVER['REMOTE_ADDR'];
$urlco = 'http://freegeoip.net/json/'.$userip.'';
$contentco = file_get_contents($urlco);
$jsonco = json_decode($contentco, true);
echo "<center><p style='color:white; text-shadow:1px 1px 3px black; font-size:20px;'>Country is";
$jsonco['country_code'];
echo "</p></center>";
?>