WordPress at a glance
function is not described

wc_make_numeric_postcode() WC 2.6.0

Make numeric postcode.

Converts letters to numbers so we can do a simple range check on postcodes. E.g. PE30 becomes 16050300 (P = 16, E = 05, 3 = 03, 0 = 00)

No Hooks.

Return

String. Nothing.

Usage

wc_make_numeric_postcode( $postcode );
$postcode(string) (required)
Regular postcode.

Changelog

Since 2.6.0 Introduced.

Code of wc_make_numeric_postcode() WC 5.2.2

<?php
function wc_make_numeric_postcode( $postcode ) {
	$postcode           = str_replace( array( ' ', '-' ), '', $postcode );
	$postcode_length    = strlen( $postcode );
	$letters_to_numbers = array_merge( array( 0 ), range( 'A', 'Z' ) );
	$letters_to_numbers = array_flip( $letters_to_numbers );
	$numeric_postcode   = '';

	for ( $i = 0; $i < $postcode_length; $i ++ ) {
		if ( is_numeric( $postcode[ $i ] ) ) {
			$numeric_postcode .= str_pad( $postcode[ $i ], 2, '0', STR_PAD_LEFT );
		} elseif ( isset( $letters_to_numbers[ $postcode[ $i ] ] ) ) {
			$numeric_postcode .= str_pad( $letters_to_numbers[ $postcode[ $i ] ], 2, '0', STR_PAD_LEFT );
		} else {
			$numeric_postcode .= '00';
		}
	}

	return $numeric_postcode;
}