Skip to content

Kirby 6.0.0

A::some()

Checks if at least one element in the array passes the test

A::some(array $array, callable(mixed $value, int|string $key, array $array): bool $test): bool

Parameters

Name Type Default
$arrayrequired array no default value
$testrequired callable(mixed $value, int|string $key, array $array): bool no default value

Return type

bool

Parent class

Kirby\Toolkit\A

Examples

$array = [1, 30, 39, 29, 10, 'foo' => 12, 13];

echo A::some($array, fn ($value) => $value > 30) ? 'a' : 'b';
// output: 'a'

echo A::some($array, fn ($value, $key) => is_string($key)) ? 'a' : 'b';
// output: 'a'