PHP code example of cbwar / php-text-difference

1. Go to this page and download the library: Download cbwar/php-text-difference 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/ */

    

cbwar / php-text-difference example snippets


composer 
 php

$options = array(
    //'ignoreWhitespace' => true,
    //'ignoreCase' => true,
);
$a = explode("\n", file_get_contents($some_file_path));
$b = explode("\n", file_get_contents($some_other_file_path);

$diff = new Diff\Diff($a, $b, $options);
$renderer = new Diff\Renderer\Html\SideBySide;
echo $diff->Render($renderer);