mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Added an additional utility function to return country name from code from the Geoip class.
This commit is contained in:
parent
dfb0504d0d
commit
dbdfa010cb
10
integration/Geoip.php
Executable file → Normal file
10
integration/Geoip.php
Executable file → Normal file
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user