Revision comparision in PHP
Question
Say, I have var1 and var2 both with a string value. Var2 is a revision of var1 with minor changes: var1:
Hello, world1
var2:
Bye bye, world!
Now I want this output:
<span class="removed">Hello</span> <span class="new">Bye bye</span>, world<span class="removed">1</span><span class="new">!</span>
much like SO's way. How can I do this in php?
Thanks
Solution
I would suggest you take a look at Text_Diff on PEAR.
OTHER TIPS
Longest common subsequence problem. Once I found nice implementation in Python and translated it into PHP (because PHP arrays are quite memory expensive I had to sacrifice speed by using string to hold LCS matrix).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow