Automattic\WooCommerce\Utilities

ArrayUtil::array_allpublic staticWC 1.0

Check if all items in an array pass a callback.

Method of the class: ArrayUtil{}

No Hooks.

Returns

true|false. true if all items pass the callback, false otherwise.

Usage

$result = ArrayUtil::array_all( $items, $callback ): bool;
$items(array) (required)
The array to check.
$callback(callable) (required)
The callback to check each item.

ArrayUtil::array_all() code WC 9.9.5

public static function array_all( array $items, callable $callback ): bool {
	if ( function_exists( 'array_all' ) ) {
		return array_all( $items, $callback );
	}
	foreach ( $items as $item ) {
		if ( ! $callback( $item ) ) {
			return false;
		}
	}
	return true;
}