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

$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

del {
ins {

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 - a demo of this diff (in side-by-side view) can be seen on

link Click to view a demo




Latest Release

Version 1.0310 weeks ago