PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Ákos Nikházy   Simple PHP String Comparison   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: Simple PHP String Comparison
Compare strings and return a similarity score
Author: By
Last change:
Date: 1 year ago
Size: 909 bytes
 

Contents

Class file image Download

simple-string-comparison

Less simple than strcmp. Compare strings letter by letter or bit by bit

It returns an int value representing the difference between two strings. For example, it gives a more precise difference between uppercase and lowercase letters, so you can decide if there is a typo between two strings. There are also letter-by-letter and binary comparisons.

Use it like this:

Letter by letter mode: This will return 1 as one letter is different (in the word fox there is a typo).

echo stringDifference::hammeringDistance('The quick brown fex jumps over the lazy dog','The quick brown fox jumps over the lazy dog')

Binary mode: This will return 2 because in binary mode the distance between the e and o in the two sentences is 2.

echo stringDifference::hammeringDistance('The quick brown fex jumps over the lazy dog','The quick brown fox jumps over the lazy dog',true));