Compare php texts

1

I need to develop / use a function to compare text in two versions, to check what has been removed / added / maintained.

One version I upload an html file and extract the plain text, and the other version I get from my database, and also extract the plain text for comparison.

Do you know of any function of this type to be used from gitHub or any other source?

I've tried using the link site function but they compare row by row, which is not functional , because in version 2 it is possible that a paragraph has been added, and if it is to compare row by row individually, from an addition, all the next comparisons will indicate modification, which is not true.

Manually, the best tool I found was link but they do not have an api or open source.

Smart enough to be clear.

Example of the output I want:

    
asked by anonymous 19.04.2018 / 15:53

2 answers

0

I found the link project on GitHub that fit perfectly with my need. The example is very interesting. And the result looks like this:

    
19.04.2018 / 20:00
2

What you are looking for is called text diff

You have a few options:

PHP Inline Diff (uses PEAR text- diff)

PEAR Text_Diff

Diff in Pure PHP

xdiff_string_diff ()

Issues related to Stackoverflow in English:

Highlight the difference between two strings in PHP

Apply Diff in PHP

Need Help Optimizing php string difference function

  

Fonts    link

    
19.04.2018 / 16:03