Automattic\WooCommerce\Blocks\Utils
StyleAttributesUtils::array_get_value_by_path
Get a value from an array based on a path e.g style.elements.link
Метод класса: StyleAttributesUtils{}
Хуков нет.
Возвращает
Разное.
Использование
$result = StyleAttributesUtils::array_get_value_by_path( $array, $path, $delimiter );
- $array(массив) (обязательный)
- Target array.
- $path(строка) (обязательный)
- Path joined by delimiter.
- $delimiter(строка)
- Chosen delimiter defaults to ".".
По умолчанию:'.'
Код StyleAttributesUtils::array_get_value_by_path() StyleAttributesUtils::array get value by path WC 11.0.1
protected static function array_get_value_by_path( array &$array, $path, $delimiter = '.' ) {
$array_path = explode( $delimiter, $path );
$ref = &$array;
foreach ( $array_path as $key ) {
if ( is_array( $ref ) && array_key_exists( $key, $ref ) ) {
$ref = &$ref[ $key ];
} else {
return null;
}
}
return $ref;
}