wc_sanitize_phone_number()WC 3.6.0

Sanitize phone number. Allows only numbers and "+" (plus sign).

No Hooks.

Return

String.

Usage

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

Changelog

Since 3.6.0 Introduced.

wc_sanitize_phone_number() code WC 8.9.0

function wc_sanitize_phone_number( $phone ) {
	return preg_replace( '/[^\d+]/', '', $phone ?? '' );
}