wc_format_country_state_string()WC 2.3.0

Formats a string in the format COUNTRY:STATE into an array.

No Hooks.

Return

Array.

Usage

wc_format_country_state_string( $country_string );
$country_string(string) (required)
Country string.

Changelog

Since 2.3.0 Introduced.

wc_format_country_state_string() code WC 8.7.0

function wc_format_country_state_string( $country_string ) {
	if ( strstr( $country_string, ':' ) ) {
		list( $country, $state ) = explode( ':', $country_string );
	} else {
		$country = $country_string;
		$state   = '';
	}
	return array(
		'country' => $country,
		'state'   => $state,
	);
}