wc_selected( string|int $value, string|int|array $options )

Return the html selected attribute if stringified $value is found in array of stringified $options or if stringified $value is the same as scalar stringified $options.


Description Description


Parameters Parameters

$value

(Required) Value to find within options.

$options

(Required) Options to go through when looking for value.


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/wc-core-functions.php

function wc_selected( $value, $options ) {
	if ( is_array( $options ) ) {
		$options = array_map( 'strval', $options );
		return selected( in_array( (string) $value, $options, true ), true, false );
	}

	return selected( $value, $options, false );
}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.