PHPackages                             ezzaze/binary-search - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ezzaze/binary-search

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ezzaze/binary-search
====================

a PHP package for searching values in large arrays faster

1.1.0(3y ago)099[1 PRs](https://github.com/ezzaze/binary-search/pulls)MITPHPPHP ^8.0CI passing

Since Sep 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ezzaze/binary-search)[ Packagist](https://packagist.org/packages/ezzaze/binary-search)[ Docs](https://github.com/ezzaze/binary-search)[ GitHub Sponsors](https://github.com/ezzaze)[ RSS](/packages/ezzaze-binary-search/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (5)Used By (0)

a PHP package for searching values in large arrays faster
=========================================================

[](#a-php-package-for-searching-values-in-large-arrays-faster)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0d8cf3816ed816a790fea1ba548bede66febe18249b7591d142925291806382a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f657a7a617a652f62696e6172792d7365617263682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ezzaze/binary-search)[![Tests](https://github.com/ezzaze/binary-search/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/ezzaze/binary-search/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/6a711b67286e5a62eff01374cccac3e3c819a69354f84255b877dc8cd93fc607/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f657a7a617a652f62696e6172792d7365617263682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ezzaze/binary-search)

A small PHP package to help you perform a search in large scale arrays with a dramatically improved performance.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require ezzaze/binary-search
```

Usage
-----

[](#usage)

```
use Ezzaze\BinarySearch\BinarySearch;

$haystack = range(1,1000000);
$result1 = BinarySearch::exists(500, $haystack); //true
$result2 = BinarySearch::exists(0, $haystack); //false
```

If you have an already pre-sorted array you can skip the sorting before search by supplying false to the 3rd parameter

```
use Ezzaze\BinarySearch\BinarySearch;

$haystack = range(1,1000000);
$result = BinarySearch::exists(500, $haystack, false);
```

The package can also be used to search for multi-demensional array within another array as shown below

```
use Ezzaze\BinarySearch\BinarySearch;

$haystack = array_chunk(range(1,1000000), 2);
$result1 = BinarySearch::exists([500,501], $haystack); //true
$result2 = BinarySearch::exists([501, 502], $haystack); //false
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Marwane Ezzaze](https://github.com/ezzaze)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 63.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~42 days

Total

3

Last Release

1249d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/af5a484b15349679f27911a7ed99e77178117d07761af3e4c8f6040a9e27e612?d=identicon)[ezzaze](/maintainers/ezzaze)

---

Top Contributors

[![ezzaze](https://avatars.githubusercontent.com/u/60152578?v=4)](https://github.com/ezzaze "ezzaze (14 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")

---

Tags

binary searchezzaze

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/ezzaze-binary-search/health.svg)

```
[![Health](https://phpackages.com/badges/ezzaze-binary-search/health.svg)](https://phpackages.com/packages/ezzaze-binary-search)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
