I want to get all country names from IP addresses. I have a CSV file in which all IP addresses are described and I want to get all country names at once. Any have an idea how to do it?
I am using the code below, but it works only for single values. How can I do this for multiple IP addresses?
<form method="post">
<input type="text" name="ip" />
<input type="submit" name="submit" value="Find" />
</form>
<?php
function countryCityFromIP($ipAddr) {
$url="http://api.ipinfodb.com/v3/ip-city/?key=5cfaab6c5af420b7b0f88d289571b990763e37b66761b2f053246f9db07ca913&ip=$ipAddr&format=json%22";
$d = file_get_contents($url);
return json_decode($d , true);
}
if(isset($_REQUEST['submit'])){
$ip=countryCityFromIP($_REQUEST['ip']);
print_r($ip);
echo $ip['countryName'];
}
?>