简体   繁体   中英

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?

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.

There is also the xdiff extension available that you can use with xdiff_file_diff function like below:

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.

Also you can use xdiff_file_diff function for comparing PHP files like below:

$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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM