
-----------------------------------
PaulButler
Thu May 17, 2007 5:56 pm

PHP Diff Algorithm
-----------------------------------
I wrote a simple diff algorithm in PHP. The functions are described in the comments; basically the "diff" function works directly on an array and the htmlDiff function is a wrapper that takes two normal strings and returns HTML markup representing the difference.

I assume that the "largest common substring" algorithm is the one I used, but I did not have any code or description to base it on so I had to figure most of it out myself. Considering diff algorithms are fairly useful and fun but challenging to code, I am surprised that there is so little information on them on the web.


