Home > Article > Backend Development > How to compare two paragraphs of text in php?
Given two paragraphs of text, how to compare them?
How to give two paragraphs of text, just like the review function of Word, mark the modification process, or similar to the correction process after dictation, compare the insertion and modification (based on characters) between two strings (paragraphs) ), delete function. Github's examples are good, but they don't seem to be minimal edits, not word-for-word operations.
For example:
Sentence 1: Why I Cann't changed it. Becuase we can't.
Sentence 2: Why we can't change it now? Because you can.
The program can compare these two sentences, find the differences, automatically skip the same parts, and mark the differences.
How does php implement this algorithm? Also give a score. Is it related to edit distance? The search keyword is: php diff? Or compare strings?
Take Hujiang as an example: http://ting.hujiang.com/mansu...
I feel that https://github.com/kijtra/tex... This algorithm is not as easy to use as Hujiang’s: