["36.70.10.246","Pulo Gebang","Indonesia","ID","-6.2088","106.9615","2021-03-24 09:49:17"]
array(6) { [0]=> string(14) "36.70.10.246" [1]=> string(7) "Pulo Gebang" [2]=> string(9) "Indonesia" [3]=> string(2) "ID" [4]=> string(7) "-6.2088" [5]=> string(8) "106.9615" [6]=> string(19) "2021-03-24 09:49:17" }
For complete result regarding the IP address information, just add : &full=1
USAGE: https://iploc.indonesiasatoe.com/api.php?ip=18.119.122.69&full=1
$ipaddr = "36.70.10.246"; function iploc($ipaddr){ $url = "https://iploc.indonesiasatoe.com/api.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "ip=" . $ipaddr); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $server_output = curl_exec($ch); curl_close ($ch); $server_output = json_decode($server_output, true); $ip = $server_output[0]; // IP ADDRESS $city = $server_output[1]; // CITY NAME $country = $server_output[2]; // COUNTRY NAME $isocode = $server_output[3]; // ISO CODE $lat = $server_output[4]; // LATITUDE $long = $server_output[5]; // LONGITUDE $datetime = $server_output[6]; // DATETIME OF REQUEST return "$city, $isocode"; }
PHP RESULT: Pulo Gebang, ID