PHP code example of baraja-core / simple-php-diff

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

    

baraja-core / simple-php-diff example snippets


$left = 'First text';
$right = 'Second text';

$diff = (new \Baraja\DiffGenerator\SimpleDiff)->compare($left, $right);

// simple render diff
echo '<code><pre>'
     . htmlspecialchars((string) $diff)
     . '</pre></code>';

echo 'Changed lines: ';
echo implode(', ', $diff->getChangedLines());

$left = 'First text';
$right = 'Second text';

$simpleDiff = new \Baraja\DiffGenerator\SimpleDiff;
$diff = $simpleDiff->compare($left, $right);

echo $simpleDiff->renderDiff($diff);

$ composer