Understanding the similarity estimate
PHP's similar_text(string $string1, string $string2, ?float &$percent = null): int returns a count of matching characters and can populate a similarity percentage. PHP uses its own recursive matching algorithm.
Important implementation difference
This browser tool does not execute PHP's similar_text() algorithm. It calculates unit-cost Levenshtein distance, derives estimated matching characters from the longer input, and reports an estimated percentage. The result is useful for quick comparisons but can differ from PHP, especially when repeated or reordered substrings are involved.
- Use the separate Levenshtein tool when edit distance is the intended metric.
- Do not use a similarity percentage as an authentication or security decision.
- Input and output stay in the browser.
- Lo awọn PHP similar_text() manual and a real PHP runtime when exact compatibility matters.