Automattic\WooCommerce\Utilities
ArrayUtil::is_truthy
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
true|false. 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() ArrayUtil::is truthy code WC 10.4.3
public static function is_truthy( array $items, string $key ) {
return isset( $items[ $key ] ) && $items[ $key ];
}