check
Definition
Description
Check if some or every array element meets specified condition.
If CHECK_SOME
flag is NOT present then every array element must meet specified condition in order to pass check.
Condition
$condition
type
Description
callable
Callable should return truthy or falsy value (while using CHECK_STRICT
flag, return values other than true
are treated as false
).
mixed
If condition type is different than callable
then every array element is compared against it value.
$value == $condition
by default
$value === $condition
if CHECK_STRICT
flag is enabled
Flags
Can be used as stand alone (i.e.Arr::CHECK_STRICT
) as well as in conjunction (i.e. Arr::CHECK_STRICT | Arr::CHECK_SOME
)
$flag
argument used to be a boolean parameter called $strict
But do not worry, it it is fully backward compatible due to in-flight type conversion from bool
to int
Constant name
Description
CHECK_STRICT
In case condition is callable
check if it result is exactly true
If condition is not callable
, then check if array element is equal to it both by value and type
See Condition section for more info
CHECK_SOME
Check will return true
on first array element that match specified condition or false if none of them matches it.
By default check
method will return true
only if ALL of array elements meet specified condition
Examples
Last updated