Automattic\WooCommerce\Utilities
ArrayUtil::array_all
Check if all items in an array pass a callback.
Method of the class: ArrayUtil{}
No Hooks.
Returns
bool. 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() ArrayUtil::array all code WC 11.0.1
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;
}