freezemage0/array_find

Provides array_find function.

1.0.1 2023-10-03 08:37 UTC

This package is auto-updated.

Last update: 2024-05-03 09:46:59 UTC


README

It's baffling that PHP in [current year] does not have a built-in array_find function, so here it is.

Usage

<?php

use function Freezemage\ArrayUtils\find as array_find;

$items = [1, 2, 3];

array_find($items, fn (int $item): bool => $item % 2 === 0); // prints 2

Also passes key associated with the value as a second parameter of a callback.