README
php diff

Compare and find differences between two strings

MFStrDiff is a simple text-string differencing class, for use in php projects, that will output the differences in plain text or in html.

The aim of MFStrDiff was to provide a simple and small developer solution with as little deployment demand as possible, and one that will not run into memory problems when the strings get large. The downside of this may be the runtime performance, but this was seen as acceptable compared with a memory exception.

The package also tries to make the diff result easier to read by keeping the minimum differences to full words (not just characters) - which does mean it likes text blocks and not blocks of encoding characters.

The code required is

php
include_once("class.MFStrDiff.php");
$diff=new MFStrDiff();
$diff->setMarkers("«","»"); // optional
$htmlOutput = true;
$diffHtml = $diff->getDiff($tx1, $tx2, $htmlOutput); 
echo "<pre>$diffHtml</pre>";

you will also need to consider creating ins and del css rules to see the differences

css
del {
   background-color:pink;
}
ins {
    background-color:palegreen;
}



info Note, this class is designed to provide a breakdown of differences between compact strings, not larger files like source code; my preference for that kind of comparison can be found in http://github.com/chrisboulton/php-diff - a demo of this diff (in side-by-side view) can be seen on methodfish.com/Articles/php-diff.


link Click to view a demo

square

About

License

Latest Release

Version 1.0310 weeks ago