[英]php Compare two large text files with each other displaying the difference
Does anyone have any good ways of comparing two large (9000+Lines) of files and highlighting the differences between the two? 有没有人能比较两个大文件(9000行以上)并突出显示两者之间的差异?
The few things i found online seem to choke and die off when i throw in large files. 当我放入大文件时,我在网上发现的一些东西似乎会窒息而死。
You can use the Text_Diff pear package for comparing the difference between 2 text files. 您可以使用Text_Diff pear包来比较2个文本文件之间的差异。
There is also the xdiff extension available that you can use with xdiff_file_diff
function like below: 还可以将xdiff扩展与xdiff_file_diff
函数一起使用,如下所示:
xdiff_file_diff('old_file.txt', 'new_file.txt', 'diff.txt');
Where diff.txt would be the resulting file with the comparison between the two files. 其中diff.txt是生成的文件,其中包含两个文件之间的比较。
Also you can use xdiff_file_diff function for comparing PHP files like below: 您也可以使用xdiff_file_diff函数比较PHP文件,如下所示:
$old_version = 'my_script.php';
$new_version = 'my_new_script.php';
xdiff_file_diff($old_version, $new_version, 'my_script.diff', 2);
// above code makes unified diff of two php files with context length of 2.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.