- file_get_contents: documentation ( source)
- json_decode: documentation ( source)
<?php
$ip = "68.180.224.179";
$result = file_get_contents('http://ipinfo.io/' . $ip . '/json');
$ipInfo = json_decode($result, true);
echo $ipInfo['country'];