wc_format_country_state_string

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

Description

(array) wc_format_country_state_string( (number) $country_string ); 

Returns (array)

Parameters (1)

0. $country_string (number)
The country string.

Usage

  1. if ( !function_exists( 'wc_format_country_state_string' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-core-functions.php'; 
  3.  
  4. // The country string. 
  5. $country_string = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_format_country_state_string($country_string); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-core-functions.php  
  1. function wc_format_country_state_string( $country_string ) { 
  2. if ( strstr( $country_string, ':' ) ) { 
  3. list( $country, $state ) = explode( ':', $country_string ); 
  4. } else { 
  5. $country = $country_string; 
  6. $state = ''; 
  7. return array( 
  8. 'country' => $country,  
  9. 'state' => $state,  
  10. );