<?php
 
 
$text_1 = 'Dies ist ein Test uber Hackfleisch.<br />Dies ist ein Text uber Hackfleisch.';
 
$text_2 = "Dies ist Text uber Kackfleisch.<br />Dies ist Test uber Kackfleisch.";
 
 
$newversion = $text_2;
 
 
$comp = new \webdof\Text\diff\Compare();
 
$diff = $comp->calcdiffer($text_1, $text_2);
 
$html.= $text_1.'<br />';
 
$html.= '<hr noshade>';
 
$html.= $text_2.'<br />';
 
$html.= '<pre>'.print_r($diff, true).'</pre>';
 
 
$back = '';
 
foreach( $diff as $step => $d)
 
 {
 
   if($d[0] === '=' || $d[0] === '-')$back.= $d[1];
 
 }
 
 
$html.=  'Patching:<br />';
 
$html.=  $back.'<br />';
 
 
 
$html.=  '<br />';
 
$html.=  'Patching Rüwärts nur mit Änderungen und strlen(equals):<br />';
 
 
$diff = $comp->minimize( $diff );
 
$oldversion = $comp->patch( $text_2, $diff );
 
 
$html.= '<pre>'.print_r($diff, true).'</pre>';
 
$html.=  $oldversion.'<br />';
 
 
$html.= '<br /><br />Test 2<br />';
 
$text_1 = 'An einem Sommertag fuhr ich mit dem Fahrrad über die Straße nach Hause.';
 
$text_2 = 'An einem schönen Sommertag ging ich mit dem Auto über die Straße spazieren.';
 
 
$html.=  $text_1.'<br />';
 
$html.=  $text_2.'<br />';
 
 
$comp = new \webdof\Text\diff\Compare();
 
$diff = $comp->calcdiffer($text_1, $text_2);
 
$diff = $comp->minimize( $diff );
 
$oldversion =  $comp->patch( $text_2, $diff );        
 
$html.= $oldversion    .'<br />';    
 
 
 
echo $html;
 
 |