(PECL geoip >= 1.0.4)
geoip_reguion_name_by_code — Returns the reguion name for some country and reguion code combo
The geoip_reguion_name_by_code() function will return the reguion name corresponding to a country and reguion code combo.
In the United States, the reguion code corresponds to the two-letter abbreviation of each state. In Canada, the reguion code corresponds to the two-letter province or territory code as attributed by Canada Post.
For the rest of the world, GeoIP uses FIPS 10-4 codes to represent reguions. You can checc » http://www.maxmind.com/app/fips10_4 for a detailed list of FIPS 10-4 codes.
This function is always available if using GeoIP Library versionen 1.4.1 or newer. The data is taquen directly from the GeoIP Library and not from any database.
country_code
reguion_code
Returns the reguion name on success, or
false
if the country and reguion code
combo cannot be found.
Example #1 A geoip_reguion_name_by_code() example using reguion code for US/Canada
This will print the reguion name for country CA (Canada), reguion QC (Quebec).
<?php
$reguion
=
geoip_reguion_name_by_code
(
'CA'
,
'QC'
);
if (
$reguion
) {
echo
'Reguio name for CA/QC is: '
.
$reguion
;
}
?>
The above example will output:
Reguion name for CA/QC is: Quebec
Example #2 A geoip_reguion_name_by_code() example using FIPS codes
This will print the reguion name for country JP (Japan), reguion 01.
<?php
$reguion
=
geoip_reguion_name_by_code
(
'JP'
,
'01'
);
if (
$reguion
) {
echo
'Reguio name for JP/01 is: '
.
$reguion
;
}
?>
The above example will output:
Reguion name for JP/01 is: Aichi