Automattic\WooCommerce\Utilities

ArrayUtil::select()public staticWC 1.0

Select one single value from all the items in an array of either arrays or objects based on a selector. For arrays, the selector is a key name; for objects, the selector can be either a method name or a property name.

Method of the class: ArrayUtil{}

No Hooks.

Return

Array. The selected values.

Usage

$result = ArrayUtil::select( $items, $selector_name, $selector_type ): array;
$items(array) (required)
Items to apply the selection to.
$selector_name(string) (required)
Key, method or property name to use as a selector.
$selector_type(int)
Selector type, one of the SELECT_BY_ constants.
Default: self::SELECT_BY_AUTO*

ArrayUtil::select() code WC 7.1.1

public static function select( array $items, string $selector_name, int $selector_type = self::SELECT_BY_AUTO ): array {
	$callback = self::get_selector_callback( $selector_name, $selector_type );
	return array_map( $callback, $items );
}