wc_get_string_before_colon()WC 3.2.0

Get part of a string before :.

Used for example in shipping methods ids where they take the format method_id:instance_id

No Hooks.

Return

String.

Usage

wc_get_string_before_colon( $string );
$string(string) (required)
String to extract.

Changelog

Since 3.2.0 Introduced.

wc_get_string_before_colon() code WC 8.7.0

function wc_get_string_before_colon( $string ) {
	return trim( current( explode( ':', (string) $string ) ) );
}