PHP Classes

File: examples.php

Recommend this page to a friend!
  Classes of Ákos Nikházy   Simple PHP String Comparison   examples.php   Download  
File: examples.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Simple PHP String Comparison
Compare strings and return a similarity score
Author: By
Last change:
Date: 6 months ago
Size: 1,294 bytes
 

Contents

Class file image Download
<?php
spl_autoload_register
(function ($class) {
    include
$class . '.class.php';
});

/* examples */
    /* string mode off for letter by letter comparison */
// int(0) the same text
var_dump(stringDifference::hammeringDistance('The quick brown fox jumps over the lazy dog','The quick brown fox jumps over the lazy dog'));

// int(1) one letter difference
var_dump(stringDifference::hammeringDistance('The quick brown fex jumps over the lazy dog','The quick brown fox jumps over the lazy dog'));

// int(1) there is a space at the end of the first string
var_dump(stringDifference::hammeringDistance('The quick brown fox jumps over the lazy dog ','The quick brown fox jumps over the lazy dog'));


   
/* bin mode on for bit by bit comparison */
// int(0) the same text
var_dump(stringDifference::hammeringDistance('The quick brown fox jumps over the lazy dog','The quick brown fox jumps over the lazy dog',true));

// int(2) one letter difference
var_dump(stringDifference::hammeringDistance('The quick brown fex jumps over the lazy dog','The quick brown fox jumps over the lazy dog',true));

// int(8) there is a space at the end of the first string
var_dump(stringDifference::hammeringDistance('The quick brown fox jumps over the lazy dog ','The quick brown fox jumps over the lazy dog',true));