1. Go to this page and download the library: Download mistralys/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/ */
mistralys / text-diff example snippets
use Mistralys\Diff\Diff;
$diff = Diff::compareStrings('String 1', 'String 2');
use Mistralys\Diff\Diff;
$diff = Diff::compareFiles('/path/to/file1', '/path/to/file2');
use Mistralys\Diff\Diff;
// Each call gets its own instance:
$string = Diff::compareFiles('/path/to/file1', '/path/to/file2')->toString();
$html = Diff::compareFiles('/path/to/file1', '/path/to/file2')->toHTML();
$table = Diff::compareFiles('/path/to/file1', '/path/to/file2')->toHTMLTable();
$array = Diff::compareFiles('/path/to/file1', '/path/to/file2')->toArray();
use Mistralys\Diff\Diff;
$diff = Diff::compareFiles('/path/to/file1', '/path/to/file2', true);
use Mistralys\Diff\Diff;
$diff = Diff::compareFiles('/path/to/file1', '/path/to/file2');
$diff->setCompareCharacters(true);
use Mistralys\Diff\Diff;
$diff = Diff::compareFiles('/path/to/file1', '/path/to/file2');
$styler = Diff::createStyler();
use Mistralys\Diff\Diff;
$styler = Diff::createStyler();
$css = $styler->getCSS(); // raw CSS string
$tag = $styler->getStyleTag(); // CSS wrapped in a <style> tag
$path = $styler->getStylesheetPath(); // absolute path to the stylesheet file
$url = $styler->getStylesheetURL('/vendor'); // URL to the file, given the vendor folder URL
$link = $styler->getStylesheetTag('/vendor'); // a full <link rel="stylesheet"> tag