wc_format_phone_number()WC 1.0

Format phone numbers.

No Hooks.

Return

String.

Usage

wc_format_phone_number( $phone );
$phone(string) (required)
Phone number.

Examples

0

#1 Formatting a phone number in Woocommerce

$phone = '8.928.123.45.67';
echo wc_format_phone_number( $phone ); //> 8-928-123-45-67

Code of wc_format_phone_number() WC 6.7.0

function wc_format_phone_number( $phone ) {
	if ( ! WC_Validation::is_phone( $phone ) ) {
		return '';
	}
	return preg_replace( '/[^0-9\+\-\(\)\s]/', '-', preg_replace( '/[\x00-\x1F\x7F-\xFF]/', '', $phone ) );
}