PHPackages                             ptachoire/file-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. ptachoire/file-binary-search

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

ptachoire/file-binary-search
============================

Binary Search in a file.

2155[1 issues](https://github.com/krichprollsch/binary-search-file/issues)PHP

Since Oct 1Pushed 13y ago1 watchersCompare

[ Source](https://github.com/krichprollsch/binary-search-file)[ Packagist](https://packagist.org/packages/ptachoire/file-binary-search)[ RSS](/packages/ptachoire-file-binary-search/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

FileBinarySearch
================

[](#filebinarysearch)

Binary search into sorted formatted file.

[![Build Status](https://camo.githubusercontent.com/b0fd9e2347050350573bead60d61481cd441e44fb43cb281dc79047bb1bc6ddc/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f6b7269636870726f6c6c7363682f62696e6172792d7365617263682d66696c652e706e67)](http://travis-ci.org/krichprollsch/binary-search-file)

Usage
-----

[](#usage)

Usage sample :

```
require_once( 'src/autoload.php');
$file = tempnam("/tmp", "sample_file_binary_search_");
file_put_contents($file, implode("\n", range(10,20,2)));

$fbs = new \FileBinarySearch\FileBinarySearch($file);

var_dump( $fbs->search(10));
/*
string(2) "10"
*/

var_dump( $fbs->search(14));
/*
string(2) "14"
*/

var_dump( $fbs->search(15));
/*
bool(false)
 */

var_dump( $fbs->search(25));
/*
bool(false)
*/

```

If you have formated lines, you can use your own comparaison method

```
function mycompare( $tested_line, $searched_value ) {
    //returns < 0 if $tested_line < $searched_value
    //returns > 0 if $tested_line > $searched_value
    //returns 0 if $tested_line == $searched_value
}

$fbs = new \FileBinarySearch\FileBinarySearch($file, 'mycompare');

```

Unit Tests
----------

[](#unit-tests)

```
phpunit

```

Thanks
------

[](#thanks)

Files structure inspired by [Geocoder](https://github.com/willdurand/Geocoder)from [William Durand](https://github.com/willdurand)

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/03b34baa5c7073b98dbf5c67e621f8467aa6178ccb84305e9e67090391f1fd99?d=identicon)[krichprollsch](/maintainers/krichprollsch)

---

Top Contributors

[![krichprollsch](https://avatars.githubusercontent.com/u/562696?v=4)](https://github.com/krichprollsch "krichprollsch (7 commits)")

### Embed Badge

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

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

###  Alternatives

[mp-php/fuel-packages-ratchet

121.9k](/packages/mp-php-fuel-packages-ratchet)

PHPackages © 2026

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