HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

array_any

Description

The array_any of Array for PHP checks if at least one array.

Syntax

array_any(
    array $array,
    callable $callback
): mixed

Parameters

array

The array that should be searched.

callback

The callback function to call to check each element, which must be

callback(
    mixed $value,
    mixed $key
): bool

If this function returns true, true is returned from array_any() and the callback will not be called for further elements.

Return

Returns true if there is at least one element for which callback returns true. Otherwise, the function returns false.

Examples

1 · array callback

<?

function callback(string $value, $key)
{
    return $key === $value[0];
}

$array =
[
    "a" => "dog",
    "b" => "cat",
    "c" => "cow"
];
$callback = "callback";

$return = array_any($array, $callback);

var_dump($return);
bool(true)