1. Go to this page and download the library: Download yusitnikov/php-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/ */
yusitnikov / php-diff example snippets
use Chameleon\PhpDiff\LevenshteinDiffCalculator;
$s1 = 'Levenshtein';
$s2 = 'Einstein';
$differ = new LevenshteinDiffCalculator();
var_dump($differ->calcDistance($s1, $s2));
var_dump($differ->calcDiff($s1, $s2));
use Chameleon\PhpDiff\LevenshteinDiffCalculator;
use Chameleon\PhpDiff\OperationCostCalculator;
$s1 = 'And now here is my secret,
a very simple secret:
it is only with the heart that one can see rightly,
what is essential is invisible to the eye.
"The Little Prince", Antoine de Saint-Exupéry';
$s2 = '> So here is my secret,
> its only with heart that somebody can see rightly,
> what is essential is always invisible to the eye.
> I can promise it to you.
- Le Petit Prince, Antoine Marie Jean-Baptiste Roger, comte de Saint-Exupéry';
$lineDiffer = new LevenshteinDiffCalculator(LevenshteinDiffCalculator::SPLIT_WORDS_REGEX);
$textDiffer = new LevenshteinDiffCalculator(
LevenshteinDiffCalculator::SPLIT_LINES_REGEX,
(new OperationCostCalculator())->setReplaceDistanceCalculator($lineDiffer),
$lineDiffer
);
$result = $textDiffer->calcDiff($s1, $s2);
cmd
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.