Permalink
Browse files

Added an additional utility function to return country name from code…

… from the Geoip class.
  • Loading branch information...
1 parent dfb0504 commit dbdfa010cba054c1377011120d9bd48a666b431c @drzax drzax committed Aug 16, 2011
Showing with 10 additions and 0 deletions.
  1. +10 −0 integration/Geoip.php
View
10 integration/Geoip.php 100755 → 100644
@@ -424,6 +424,16 @@ static function countryCode2name($code) {
$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

0 comments on commit dbdfa01

Please sign in to comment.