PHPackages                             ihsandevs/php-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. [Search &amp; Filtering](/categories/search)
4. /
5. ihsandevs/php-binary-search

ActiveLibrary[Search &amp; Filtering](/categories/search)

ihsandevs/php-binary-search
===========================

A PHP implementation of the Binary Search algorithm

v1.0.0(3y ago)112MITPHPPHP &gt;=7.2

Since Mar 15Pushed 3y ago1 watchersCompare

[ Source](https://github.com/IhsanDevs/PhpBinarySearch)[ Packagist](https://packagist.org/packages/ihsandevs/php-binary-search)[ Docs](https://github.com/IhsanDevs/PhpBinarySearch)[ RSS](/packages/ihsandevs-php-binary-search/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Binary Search
=============

[](#binary-search)

About
-----

[](#about)

Binary Search is a search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the middle element of the array. If they are not equal, the half in which the target cannot lie is eliminated and the search continues on the remaining half, again taking the middle element to compare to the target value, and repeating this until the target value is found. If the search ends with the remaining half being empty, the target is not in the array.

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

[](#installation)

```
composer require ihsandevs/php-binary-search
```

Usage
-----

[](#usage)

1. Search with default comparison function

```
