Automattic\WooCommerce\Internal\Admin\ProductForm
Component::get_argument_from_path
Gets argument by dot notation path.
Method of the class: Component{}
No Hooks.
Returns
Mixed|null.
Usage
$result = Component::get_argument_from_path( $arguments, $path, $delimiter );
- $arguments(array) (required)
- Arguments array.
- $path(string) (required)
- Path for argument key.
- $delimiter(string)
- Path delimiter, default:
'.'.
Default:'.'
Component::get_argument_from_path() Component::get argument from path code WC 10.5.0
public static function get_argument_from_path( $arguments, $path, $delimiter = '.' ) {
$path_keys = explode( $delimiter, $path );
$num_keys = false !== $path_keys ? count( $path_keys ) : 0;
$val = $arguments;
for ( $i = 0; $i < $num_keys; $i++ ) {
$key = $path_keys[ $i ];
if ( array_key_exists( $key, $val ) ) {
$val = $val[ $key ];
} else {
$val = null;
break;
}
}
return $val;
}