开发者

compare 4 or more files

开发者 https://www.devze.com 2023-01-24 06:48 出处:网络
Is there a command line utility or a php/py script that will generate a html diff so that multiple files can be compared in order to compare 4 or more files.

Is there a command line utility or a php/py script that will generate a html diff so that multiple files can be compared in order to compare 4 or more files.

Each of my files have max of 10k lines each.

开发者_开发百科

Note: these files are plain text files . not html . Only contain A-Za-z0-9=., . and no HTML tags


It depends what type of data you're comparing/analyzing.

The basic solution is

  • file_get_contents gives you strings of the file data
  • strcmp will do a "binary-safe compare" of the data

You will probably want to explode() your data to delimit it somehow, and compare sections of the data.

Another option is to delimit, loop through, and make a "comparison coefficient" which would indicate to what degree the files deviate from a norm. For example, File 1 has cc=3, file 4 has cc=8. File 4 would be a closer match.

A final problem you'll run into is the memory limit on the server computer. You can change this in php.ini.

//EDIT

Just noticed the diff tag, but I'll leave this up anyway in case it helps somehow.

0

精彩评论

暂无评论...
验证码 换一张
取 消