Automattic\WooCommerce\Utilities

ArrayUtil::is_truthy()public staticWC 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.

Return

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

Usage

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

ArrayUtil::is_truthy() code WC 8.7.0

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