PHP code example of kijtra / textdiff

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

    

kijtra / textdiff example snippets



use Kijtra\TextDiff\TextDiff;

$old_text = "abcg efgh ijk";

$new_text = "abcg efg hijk";

$diff = new TextDiff($old_text, $new_text);

// Get raw data
$data = $diff->getData();

// Get HTML data (use table tag)
$html = $diff->getHtml();

  
   new TextDiff($text1, $text2);
  

  
  use Kijtra\TextDiff\TextDiff;
  $diff = new TextDiff($text1, $text2);
  

  
  // 配列で取得
  $diff = text_diff($text1, $text2);

  // HTMLで取得
  $html = text_diff_html($text1, $text2);