$user_ip = getenv('REMOTE_ADDR');
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$user_ip"));
$city = $geo["geoplugin_city"];
$region = $geo["geoplugin_regionName"];
$country = $geo["geoplugin_countryName"];
$continent = $geo["geoplugin_continentCode"];
$continent1 = $continent;
echo "IP: " .$user_ip. "<br>";
echo "City: " .$city. "<br>";
echo "Region: " .$region. "<br>";
echo "Country: " .$country. "<br>";
echo "Continent: " .$continent1. "<br>";
This code is for getting the IP and location details.
Here, my problem is, I am getting continents as AS, EU, NA, SA
I need to change AS to Asia, EU to Europe, NA to North America and SA to South America. How to use an if else condition for this?
ifjust in case if your array is not exhaustive).