PHPackages                             eloquent/lcs - 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. eloquent/lcs

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

eloquent/lcs
============

An implementation of the 'longest common subsequence' algorithm for PHP.

2.0.0(12y ago)17352.9k—0%4[2 issues](https://github.com/eloquent/php-lcs/issues)MITPHPPHP &gt;=5.3

Since Aug 15Pushed 2y ago3 watchersCompare

[ Source](https://github.com/eloquent/php-lcs)[ Packagist](https://packagist.org/packages/eloquent/lcs)[ Docs](https://github.com/eloquent/php-lcs)[ RSS](/packages/eloquent-lcs/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (7)Used By (0)

> # No longer maintained
>
> [](#no-longer-maintained)
>
> This package is no longer maintained. See [this statement](https://gist.github.com/ezzatron/713a548735febe3d76f8ca831bc895c0) for more info.

PHP-LCS
=======

[](#php-lcs)

*An implementation of the 'longest common subsequence' algorithm for PHP.*

[![The most recent stable version is 2.0.0](https://camo.githubusercontent.com/14292701dabbd874c065e08be17dde83a526fb7d21a7874f6d068c1467bc4554/687474703a2f2f696d672e736869656c64732e696f2f3a73656d7665722d322e302e302d627269676874677265656e2e737667 "This project uses semantic versioning")](http://semver.org/)[![Current build status image](https://camo.githubusercontent.com/ef8c37351273c5473387af5561e27284fd5a46dc64a33adc06f957ea33467b23/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f656c6f7175656e742f7068702d6c63732f646576656c6f702e737667 "Current build status for the develop branch")](https://travis-ci.org/eloquent/php-lcs)[![Current coverage status image](https://camo.githubusercontent.com/7d51cb372ac622d0516061d8694c50064e433ccf826466f43e1ab58b33455a0c/687474703a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f656c6f7175656e742f7068702d6c63732f646576656c6f702e737667 "Current test coverage for the develop branch")](https://coveralls.io/r/eloquent/php-lcs)

Installation and documentation
------------------------------

[](#installation-and-documentation)

- Available as [Composer](http://getcomposer.org/) package [eloquent/lcs](https://packagist.org/packages/eloquent/lcs).
- [API documentation](http://lqnt.co/php-lcs/artifacts/documentation/api/) available.

What is PHP-LCS?
----------------

[](#what-is-php-lcs)

*PHP-LCS* is a PHP implementation of an algorithm to solve the 'longest common subsequence' problem.

From [Wikipedia - longest common subsequence problem](http://en.wikipedia.org/wiki/Longest_common_subsequence_problem):

> The **longest common subsequence (LCS) problem** is to find the longest [subsequence](http://en.wikipedia.org/wiki/Subsequence) common to all sequences in a set of sequences (often just two). Note that subsequence is different from a substring, see [substring vs. subsequence](http://en.wikipedia.org/wiki/Subsequence#Substring_vs._subsequence). It is a classic [computer science](http://en.wikipedia.org/wiki/Computer_science) problem, the basis of [file comparison](http://en.wikipedia.org/wiki/File_comparison) programs such as [diff](http://en.wikipedia.org/wiki/Diff), and has applications in [bioinformatics](http://en.wikipedia.org/wiki/Bioinformatics).

Usage
-----

[](#usage)

```
use Eloquent\Lcs\LcsSolver;

$solver = new LcsSolver;

$sequenceA = array('B', 'A', 'N', 'A', 'N', 'A');
$sequenceB = array('A', 'T', 'A', 'N', 'A');

// calculates the LCS to be array('A', 'A', 'N', 'A')
$lcs = $solver->longestCommonSubsequence($sequenceA, $sequenceB);
```

Elements in sequences can be anything. By default, sequence members are compared using the `===` operator. To customize this comparison, simply construct the solver with a custom comparator, like so:

```
use Eloquent\Lcs\LcsSolver;

$solver = new LcsSolver(
    function ($left, $right) {
        // return true if $left and $right are equal
    }
);
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~138 days

Total

5

Last Release

4474d ago

Major Versions

1.0.3 → 2.0.02014-02-17

PHP version history (2 changes)1.0.0PHP &gt;=5

2.0.0PHP &gt;=5.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/100152?v=4)[Erin](/maintainers/ezzatron)[@ezzatron](https://github.com/ezzatron)

---

Top Contributors

[![ezzatron](https://avatars.githubusercontent.com/u/100152?v=4)](https://github.com/ezzatron "ezzatron (16 commits)")

---

Tags

diffcommonAlgorithmsequencelongestsubsequence

### Embed Badge

![Health badge](/badges/eloquent-lcs/health.svg)

```
[![Health](https://phpackages.com/badges/eloquent-lcs/health.svg)](https://phpackages.com/packages/eloquent-lcs)
```

###  Alternatives

[phpcollection/phpcollection

General-Purpose Collection Library for PHP

1.0k64.0M34](/packages/phpcollection-phpcollection)[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.4M28](/packages/rubix-ml)[league/period

Time range API for PHP

7335.4M21](/packages/league-period)[jfcherng/php-diff

A comprehensive library for generating differences between two strings in multiple formats (unified, side by side HTML etc).

4705.1M51](/packages/jfcherng-php-diff)[caxy/php-htmldiff

A library for comparing two HTML files/snippets and highlighting the differences using simple HTML.

21320.9M15](/packages/caxy-php-htmldiff)[phpoffice/common

PHPOffice Common

23512.3M36](/packages/phpoffice-common)

PHPackages © 2026

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