dev-master
9999999-devSorts haystack with strings by Levenshtein distance to needle
GPL-2.0
The Requires
- php >=5.3.2
The Development Requires
by Valentinas BartuseviÄius
array sort levenshtein
Sorts haystack with strings by Levenshtein distance to needle
Sorts given array of strings by Levenshtein distance., (*1)
Simply use:, (*2)
$needle = 'text'; $haystack = array('texas', 'test', 'random'); $sorter = new ArraySort(); $result = $sorter->sort($needle, $haystack); print_r($result);
The result will be represented as ordered array with keys as Levenshtein distance to needle:, (*3)
Array ( [1] => test [2] => texas [6] => random )
In case there are same distances to needle, the nested array will be created:, (*4)
$needle = 'text'; $haystack = array('texas', 'test', 'texts', 'random'); $result = $sorter->sort($needle, $haystack); print_r($result);
Array ( [1] => Array ( [0] => test [1] => texts ) [2] => texas [6] => random )
composer require v-bartusevicius/levenshtein-array-sort
, (*5)
Sorts haystack with strings by Levenshtein distance to needle
GPL-2.0
array sort levenshtein