<?php
$array = [
'a' => 'dog',
'b' => 'cat',
'c' => 'cow',
'd' => 'duck',
'e' => 'goose',
'f' => 'elephant'
];
// Check, if any animal name is longer than 5 letters.
var_dump(array_any($array, function (string $value) {
return strlen($value) > 5;
}));
// Check, if any animal name is shorter than 3 letters.
var_dump(array_any($array, function (string $value) {
return strlen($value) < 3;
}));
// Check, if any array key is not a string.
var_dump(array_any($array, function (string $value, $key) {
return !is_string($key);
}));
?>
bool(true)
bool(false)
bool(false)