PHPackages                             wxb/funcompare - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. wxb/funcompare

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

wxb/funcompare
==============

A tool compare text differences

1.4(6y ago)135MITPHPPHP &gt;=5.4

Since Feb 28Pushed 6y agoCompare

[ Source](https://github.com/wxb/funcompare)[ Packagist](https://packagist.org/packages/wxb/funcompare)[ Docs](https://github.com/wxb/funcompare)[ RSS](/packages/wxb-funcompare/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (1)Versions (6)Used By (0)

funcompare
==========

[](#funcompare)

A tool compare text differences

声明
==

[](#声明)

- 1. 本工具Fork自
- 2. 在原工具基础上修改BUG并添加单元测试后输出
- 3. 由于原作者已不再更新，本人fork后准备长期补充、支持和优化，遂形成本库：

Installation
============

[](#installation)

```
composer require "wxb/funcompare"

```

Usage
=====

[](#usage)

### compareText($oldString, $newString)

[](#comparetextoldstring-newstring)

```
use Wxb\Funcompare\Funcompare;

$old = 'A tool compare text differences is funny';
$new = 'A tool that compare text differences';

$fc = new Funcompare();
$res = $fc->compareText($old, $new);
echo $res;

// A tool  compare text differences
```

### compareArray($oldArr, $newArr)

[](#comparearrayoldarr-newarr)

```
use Wxb\Funcompare\Funcompare;

$old = [
    ["id" => 1, "name" => "xxx", "age" => 18, "cart" => [["id" => 100, "name" => "rice->你"]], "sex" => "男/0"],
    ["id" => 2, "name" => "aaa", "age" => 18],
];
$new = [
    ["id" => 1, "name" => "yyy", "age" => 20, "cart" => [["id" => 100, "name" => "banana/我"]], "sex" => 1, "address" => ["provice" => "陕西省", "city" => "宝鸡市"]],
    ["id" => 2, "name" => "bbb", "age" => 18],
];

$fc = new Funcompare();
$res = $fc->compareArray($old, $new);
var_export($res);

/*
array (
  0 =>
  array (
    'name' =>
    array (
      'old' => 'xxx',
      'new' => 'yyy',
    ),
    'age' =>
    array (
      'old' => 18,
      'new' => 20,
    ),
    'cart' =>
    array (
      0 =>
      array (
        'name' =>
        array (
          'old' => 'rice->你',
          'new' => 'banana/我',
        ),
      ),
    ),
    'sex' =>
    array (
      'old' => '男/0',
      'new' => 1,
    ),
    'address' =>
    array (
      'old' => NULL,
      'new' =>
      array (
        'provice' => '陕西省',
        'city' => '宝鸡市',
      ),
    ),
  ),
  1 =>
  array (
    'name' =>
    array (
      'old' => 'aaa',
      'new' => 'bbb',
    ),
  ),
)
*/
```

### compareJson($oldJson, $newJson)

[](#comparejsonoldjson-newjson)

```
use Wxb\Funcompare\Funcompare;

$old = '[{"id":1,"name":"xxx","age":18,"cart":[{"id":100,"name":"rice->你"}], "sex":"男/0"},{"id":2,"name":"aaa","age":18}]';
$new = '[{"id":1,"name":"yyy","age":20,"cart":[{"id":100,"name":"banana/我"}], "sex":1, "address":{"provice":"陕西省","city":"宝鸡市"}},{"id":2,"name":"bbb","age":18}]';

$fc = new Funcompare();
$res = $fc->compareJson($old, $new);
echo $res

// [{"name":{"old":"xxx","new":"yyy"},"age":{"old":18,"new":20},"cart":[{"name":{"old":"rice->你","new":"banana/我"}}],"sex":{"old":"男/0","new":1},"address":{"old":null,"new":{"provice":"陕西省","city":"宝鸡市"}}},{"name":{"old":"aaa","new":"bbb"}}]
```

```
[
    {
        "name":{
            "old":"xxx",
            "new":"yyy"
        },
        "age":{
            "old":18,
            "new":20
        },
        "cart":[
            {
                "name":{
                    "old":"rice->你",
                    "new":"banana/我"
                }
            }
        ],
        "sex":{
            "old":"男/0",
            "new":1
        },
        "address":{
            "old":null,
            "new":{
                "provice":"陕西省",
                "city":"宝鸡市"
            }
        }
    },
    {
        "name":{
            "old":"aaa",
            "new":"bbb"
        }
    }
]
```

### label($oldLabel, $newLabel)

[](#labeloldlabel-newlabel)

```
use Wxb\Funcompare\Funcompare;

$fromA = 'A tool compare text differences is funny';
$fromB = 'A tool that compare text differences';

$fc = new Funcompare();
$res = $fc->label('a', 'b')->compareText($fromA, $fromB);
echo $res;

// A tool  compare text differences
```

License
=======

[](#license)

MIT

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 88.9% 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 ~201 days

Total

5

Last Release

2197d ago

PHP version history (2 changes)1.0PHP &gt;=5.3

1.3PHP &gt;=5.4

### Community

Maintainers

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

---

Top Contributors

[![shuixn](https://avatars.githubusercontent.com/u/7775361?v=4)](https://github.com/shuixn "shuixn (8 commits)")[![wxb](https://avatars.githubusercontent.com/u/7111495?v=4)](https://github.com/wxb "wxb (1 commits)")

---

Tags

jsoncomparetextdifference

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wxb-funcompare/health.svg)

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

###  Alternatives

[justinrainbow/json-schema

A library to validate a json schema.

3.6k316.9M612](/packages/justinrainbow-json-schema)[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k135.8M851](/packages/jms-serializer)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[colinodell/json5

UTF-8 compatible JSON5 parser for PHP

30422.2M45](/packages/colinodell-json5)[clue/ndjson-react

Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.

15467.7M16](/packages/clue-ndjson-react)

PHPackages © 2026

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