问题描述
我正在使用Text_Diff PEAR包来区分到短文本文档,其中Text_Diff对象是用每个文档中用空格分隔的单词列表创建的。我希望将差异存储在数据库中,然后在再次加载文件时应用它。有没有简单的方法可以应用该差异,还是我需要编写一个函数来对其进行解析?
I'm working with the Text_Diff PEAR package to diff to short text documents, where the Text_Diff object is created with a space-delimited list of the words in each document. I was hoping to store the diff in a database, and then apply it when the file is loaded again. Is there an easy way to apply this diff, or do I need to write a function to parse it?
推荐答案
php xdiff扩展名支持从文件和字符串打补丁。查看Text_Diff的源代码,我看到它使用xdiff来执行差异。您应该可以使用进行补丁或其中一些同级功能。
The php xdiff extension supports patching from both files and strings. Looking at the source for Text_Diff I see that it uses xdiff for performing the diffs. You should be able to patch using xdiff_string_patch() or some of it's sibling functions.
这篇关于在PHP中应用Diff的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!