ArrayUtil::get_value_or_default()public staticWC 1.0

Gets the value for a given key from an array, or a default value if the key doesn't exist in the array.

{} It's a method of the class: ArrayUtil{}

No Hooks.


Mixed|null. The value for the key, or the default value passed.


$result = ArrayUtil::get_value_or_default( $array, $key, $default );
$array(array) (required)
The array to get the value from.
$key(string) (required)
The key to use to retrieve the value.
The default value to return if the key doesn't exist in the array.
Default: null

Code of ArrayUtil::get_value_or_default() WC 7.1.0

public static function get_value_or_default( array $array, string $key, $default = null ) {
	return isset( $array[ $key ] ) ? $array[ $key ] : $default;