wc_normalize_postcode

Normalize postcodes.

Description

(string) wc_normalize_postcode( (string) $postcode ); 

Remove spaces and convert characters to uppercase.

Returns (string)

Sanitized postcode.

Parameters (1)

0. $postcode (string)
The postcode.

Usage

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

Defined (1)

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

/includes/wc-formatting-functions.php  
  1. function wc_normalize_postcode( $postcode ) { 
  2. $postcode = function_exists( 'mb_strtoupper' ) ? mb_strtoupper( $postcode ) : strtoupper( $postcode ); 
  3. return preg_replace( '/[\s\-]/', '', trim( $postcode ) );