Skip to content
This repository was archived by the owner on Mar 25, 2026. It is now read-only.

oliver-dvorski/array_find

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ℹ️ As of php 8.4, this function is natively supported by php.

Install the dependencies with composer install.

You can confirm that the program does what it should by running the composer test script.

Usage

$people = [
  ['name' => 'John', 'age' => 20],
  ['name' => 'Jane', 'age' => 21],
  ['name' => 'Jack', 'age' => 22],
];

// Returns ['name' => 'Jane', 'age' => 21]
$found = array_find($people, fn($item) => $item['name'] === 'Jane');

About

array_find for php. It stops the linear search when the first match is found.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages