Skip to content

Add new method: array_find #13996

Closed
@nicoalonso

Description

@nicoalonso

Description

Description

Add a new method called: "array_find"

This method could have the following signature:

function array_find(array $haystack, callable $callback): mixed {}

This method should have the same behavior as javascript's 'Array.prototype.find' method (mdn doc)

Example:

$data = ['dummy' => 'test',];
$keys = ['key1', 'dummy', 'key2'];
$result = array_find($keys, fn($key) => array_key_exists($key, $data));
echo $result;
// echo: dummy

PHP Version

N/A

Operating System

N/A

Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions