Automattic\WooCommerce\Utilities

ArrayUtil::is_truthy │ public static │ WC 1.0

Checks if a given key exists in an array and its value can be evaluated as 'true'.

Method of the class: ArrayUtil{}

No Hooks.

Returns

bool. True if the key exists in the array and the value can be evaluated as 'true'.

Usage

$result = ArrayUtil::is_truthy( $items, $key );
$items(array) (required)
The array to check.
$key(string) (required)
The key for the value to check.

ArrayUtil::is_truthy() code WC 11.2.2

public static function is_truthy( array $items, string $key ) {
	return isset( $items[ $key ] ) && $items[ $key ];
}