PHP code example of topvisor / horde-text-diff

1. Go to this page and download the library: Download topvisor/horde-text-diff library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

topvisor / horde-text-diff example snippets


use Topvisor\Horde\Text\Diff;

$diff = Diff\Diff::fromFileLineArrays($linesA, $linesB);

// calc diff as word
$renderer = new Diff\InlineRenderer();
$res = $renderer->render($diff);
var_dump($res);

// calc diff as symbol
$renderer = new Topvisor\Horde\Text\Diff\InlineRenderer(['split_characters' => true]);
$res2 = $renderer->render($diff);
var_dump($res2);