WC_Countries::get_continent_code_for_country( string $cc )
Get continent code for a country code.
Description Description
Parameters Parameters
- $cc
-
(Required) Country code.
Return Return
(string)
Source Source
File: includes/class-wc-countries.php
public function get_continent_code_for_country( $cc ) {
$cc = trim( strtoupper( $cc ) );
$continents = $this->get_continents();
$continents_and_ccs = wp_list_pluck( $continents, 'countries' );
foreach ( $continents_and_ccs as $continent_code => $countries ) {
if ( false !== array_search( $cc, $countries, true ) ) {
return $continent_code;
}
}
return '';
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.6.0 | Introduced. |