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'.

Метод класса: ArrayUtil{}

Хуков нет.

Возвращает

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

Использование

$result = ArrayUtil::is_truthy( $array, $key );
$array(массив) (обязательный)
The array to check.
$key(строка) (обязательный)
The key for the value to check.

Код ArrayUtil::is_truthy() WC 8.7.0

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