I have the following:
$sim1 = similar_text(strtolower('Hvar Port'), strtolower('Il Porto'));
$sim2 = similar_text(strtolower('Hvar Port'), strtolower('Port of Hvar'));
Of course, $sim2
logically is the more similar text to most humans.
However, this is the output:
$sim1: 5
$sim2: 4
So it thinks that “Il Porto” is more similar, which it’s not.
I’ve also tried the levenshtein()
function but that seems to give similar results (the lower the better):
$sim1: 5
$sim2: 11
So what function can I use to actually get the most similar text? Are there any better libraries out there that are a little more “modern”?