This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Levenshtein distance with multibyte support | |
// Improved from https://gist.github.com/santhoshtr/1710925 | |
function mb_levenshtein($str1, $str2, $encoding = 'UTF-8', $return_lengths = false){ | |
$length1 = mb_strlen($str1, $encoding); | |
$length2 = mb_strlen($str2, $encoding); | |
if( $str1 === $str2) { | |
if ($return_lengths) { | |
return array(0, $length1, $length2); | |
} else { |