ammarmidani / laravel-string-similarities
Compare between two strings and get a similarity percentage
2.0
2020-02-29 13:53 UTC
Requires
- php: ~7.0
This package is auto-updated.
Last update: 2025-07-29 01:52:48 UTC
README
Compare two string and get a similarity percentage.
Install
You can install this package via composer:
$ composer require ammarmidani/laravel-string-similarities
Usage
$comparison = new \AmmarMidani\StringSimilarity\Compare(); // the functions returns similarity percentage between strings $jaroWinkler = $comparison->jaroWinkler('first string', 'second string'); // JaroWinkler comparison $levenshtein = $comparison->levenshtein('first string', 'second string'); // Levenshtein comparison $smg = $comparison->smg('first string', 'second string'); // Smith Waterman Gotoh comparison $similar = $comparison->similarText('first string', 'second string'); // Using "similar_text()" // This next one will return an array containing the results of all working comparison methods // plus an array of 'data' that includes the first and second string, and the time in second it took to run all // comparison. BE AWARE that comparing long string can results in really long compute time! $all = $comparison->all('first string', 'second string');