Bitrix API

Diff

This Class implements the Difference Algorithm published in "An O(ND) Difference Algorithm and its Variations" by Eugene Myers Algorithmica Vol. 1 No. 2, 1986, p 251.

Table of Contents

Methods

getDiffHtml()  : string
Function finds the difference between two versions of text and creates html output with highlighted edits to transform text from first to second version.
getDiffScript()  : array<string|int, mixed>
Function compares two arrays and creates edit script, that is required to transform array $a to array $b

Methods

getDiffHtml()

Function finds the difference between two versions of text and creates html output with highlighted edits to transform text from first to second version.

public getDiffHtml(string $a, string $b) : string
Parameters
$a : string

First version of text to be compared.

$b : string

Second version of text to be compared.

Return values
string

getDiffScript()

Function compares two arrays and creates edit script, that is required to transform array $a to array $b

public getDiffScript(array<string|int, mixed> $a, array<string|int, mixed> $b) : array<string|int, mixed>
Parameters
$a : array<string|int, mixed>

First array to be compared.

$b : array<string|int, mixed>

Second array to be compared.

Return values
array<string|int, mixed>

Array of edit steps to transform array $a to array $b. Each step is an array with keys:

  • startA - position in array $a
  • startB - position in array $b
  • deletedA - count of elements deleted from array $a
  • insertedB - count of elements inserted from array $b.
  • 
            
    On this page

    Search results