From dbdfa010cba054c1377011120d9bd48a666b431c Mon Sep 17 00:00:00 2001 From: drzax Date: Tue, 16 Aug 2011 15:24:52 +1000 Subject: [PATCH] Added an additional utility function to return country name from code from the Geoip class. --- integration/Geoip.php | 10 ++++++++++ 1 file changed, 10 insertions(+) mode change 100755 => 100644 integration/Geoip.php diff --git a/integration/Geoip.php b/integration/Geoip.php old mode 100755 new mode 100644 index 8b8ad6864..bf87d2f91 --- a/integration/Geoip.php +++ b/integration/Geoip.php @@ -424,6 +424,16 @@ class Geoip { $name = isset(Geoip::$iso_3166_countryCodes[$code]) ? Geoip::$iso_3166_countryCodes[$code] : null; return $name; } + + /** + * Returns the country code from a country name. + * + * @return null|string String if the country name is found, null otherwise + */ + static function countryName2code($name) { + $code = array_search($name, Geoip::$iso_3166_countryCodes); + return ($code) ? $code : null; + } /** * Returns an array of ISO Country Codes -> Country Names