PHP code example of jsandersuk / string-diffs

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

    

jsandersuk / string-diffs example snippets


$stylist = new JSandersUK\StringDiffs\Stylists\ConsoleStylist();
$calculator = new JSandersUK\StringDiffs\Calculator($stylist);

$styledDifferenceText = $calculator->diff($old, $new);
print $styledDifferenceText;

$stylist = new JSandersUK\StringDiffs\Stylists\ConsoleStylist();

$stylist = new JSandersUK\StringDiffs\Stylists\ConsoleStylist(
    Bramus\Ansi\ControlSequences\EscapeSequences\Enums\SGR::COLOR_FG_WHITE,
    Bramus\Ansi\ControlSequences\EscapeSequences\Enums\SGR::COLOR_BG_RED,
    Bramus\Ansi\ControlSequences\EscapeSequences\Enums\SGR::COLOR_FG_WHITE,
    Bramus\Ansi\ControlSequences\EscapeSequences\Enums\SGR::COLOR_BG_GREEN
);

$stylist = new JSandersUK\StringDiffs\Stylists\HtmlStylist();;

$stylist = new JSandersUK\StringDiffs\Stylists\HtmlStylist(
    'old-text',
    'new-text',
    'div'
);