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.

Метод класса: ArrayUtil{}

Хуков нет.

Возвращает

Массив. The selected values.

Использование

$result = ArrayUtil::select( $items, $selector_name, $selector_type ): array;
$items(массив) (обязательный)
Items to apply the selection to.
$selector_name(строка) (обязательный)
Key, method or property name to use as a selector.
$selector_type(int)
Selector type, one of the SELECT_BY_ constants.
По умолчанию: self::SELECT_BY_AUTO*

Код ArrayUtil::select() WC 8.7.0

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 );
}