wxb/funcompare 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wxb/funcompare

Composer 安装命令:

composer require wxb/funcompare

包简介

A tool compare text differences

README 文档

README

A tool compare text differences

声明

Installation

composer require "wxb/funcompare"

Usage

compareText($oldString, $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 <new:that> compare text differences <old:is> <old:funny>

compareArray($oldArr, $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)

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)

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 <b:that> compare text differences <a:is> <a:funny> 

License

MIT

统计信息

  • 总下载量: 35
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固