PHP code example of lolli42 / finediff

1. Go to this page and download the library: Download lolli42/finediff 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/ */

    

lolli42 / finediff example snippets


echo (new Diff())->render('hello world', 'hello2 worlds');

echo (new Diff())->render('string one', 'string two');

echo (new Diff(new Word()))->render('string one', 'string two');

echo (new Diff())->render('foo<bär>baz', 'foo<qüx>baz');

$diff = new Diff();
echo $diff->getOpcodes('hello world', 'hello2 worlds');
// c5i:2c6i:s
// Means: copy 5 chars "hello", then insert "2", then copy 6 chars " world", then insert "s"
echo $diff->process('hello wordl', 'c5i:2c6i:s');
// hello<ins>2</ins> world<ins>s</ins>