Log In Register
c
Get country, country code, latitude and longitude from IP address PHP using free API:

<?php
$ip = '123.45.67.89';
$data = json_decode(file_get_contents('http://api.rest7.com/v1/ip_to_country.php?ip=' . $ip));

if (@$data->success !== 1)
{
    die('Failed');
}
echo '2 letter Code=' . $data->code . '<br>';
echo '3 letter Code=' . $data->code3 . '<br>';
echo 'Country=' . $data->country . '<br>';
echo 'Latitude=' . $data->lat . '<br>';
echo 'Longitude=' . $data->lng . '<br>';