如何使用PHP进行文本DIFF? [英] How to do text DIFF using PHP?

查看:82
本文介绍了如何使用PHP进行文本DIFF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为PHP做到这一点的最佳方法是什么?考虑到列内容可能很大,是否有任何PHP函数可以做到这一点?

What is the best way to do this for PHP? Is there any PHP function that can do this, considering the column content could be very large?

如果没有PHP函数,我可以调用什么shell实用程序?

If PHP function is not available, what shell utility can I call?

谢谢

推荐答案

PHP中没有内置的diff函数.但是,对于PEAR来说,则是hooray: Text_Diff (从来没有用过,但我相信PEAR是很困难的).

there aren't any built in diff functions in PHP. but, hooray for PEAR: Text_Diff (never used it tough, but in PEAR i trust).

甚至还有一个PECL软件包, xdiff

and there's even a PECL package, xdiff

提示:pear类是纯php,pecl包是模块.通常,模块比类要快,但是它也取决于功能.您只需要测试和评估.

hint: pear classes are pure php, pecl packages are modules. normally, modules are faster than classes, but it also depends on the functionality. you just have to test and evaluate.

用于存储:我将存储纯文本,而不是差异.空间便宜,许多数据库(例如mysql)都支持数据压缩(或者您可以在php中解压缩),但是如果存储纯文本,则独立于diff算法,以后可以在需要时进行更改.

for storing: i'd store the plain text, not the diffs. space is cheap, many databases (e.g. mysql) support data compression (or you could de/compress in php), but if you store the plaintext, you're independent of the diff algorithm and can change it later if needed.

如果需要速度,可以同时存储纯文本和差异.

if you need speed, you could store both the plaintexts AND the diffs.

这篇关于如何使用PHP进行文本DIFF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆