What is the best PHP class to compare strings? #diff compare string
Edit
by Calmette - 9 years ago (2015-02-27)
Compare strings
| I want to compare strings and get the differences between them. |
Ask clarification
2 Recommendations
PHP Diff Text Strings: Find differences between texts and patch strings
This class can find differences between texts and patch strings.
It can compare two given text strings and return the differences between them.
The class can also patch the original string using an optimized version of the difference information to obtain the second string.
| by Melanie Wehowski package author 135 - 9 years ago (2015-03-05) Comment This class has similar functionality. It does not render the differences for you, but provides an optimized compressed version (to save space) of the differences and also can patch back to the original string from the optimized differences.
However, if you need the class to render the differences you should prefer the above class of Manuel Lemos. |
This class can find and view the difference between text strings.
It takes two text strings and uses the diff algorithm to find the differences between them and return a list of changes to patch the original string to become the final string.
The patch list shows what text should be added or removed to change one string into the other.
The difference between the text strings may be computed in three modes: by character, by word or by line.
The class may also format the strings to view them as HTML showing which characters are added and removed with special insertion and deleted styles.
The example page works as a tool to interactively view the changes as the user changes the texts before and after the changes are applied.
The class can also patch the original string using the patch list to regenerated the changed string.
| by Manuel Lemos package author 26695 - 9 years ago (2015-03-04) Comment This class can compare two strings and return the list of changes to turn one string into the other, like lines or characters to add or removed.
It can also present the string changes in HTML so you can view them in a Web page. |