【文件属性】:
文件名称:levenshtein-array-sort:按 Levenshtein 距离对给定的字符串数组进行排序
文件大小:11KB
文件格式:ZIP
更新时间:2021-06-20 18:13:17
PHP
Levenshtein 数组排序
按 Levenshtein 距离对给定的字符串数组进行排序。
只需使用:
$ needle = 'text' ;
$ haystack = array ( 'texas' , 'test' , 'random' );
$ sorter = new ArraySort ();
$ result = $ sorter -> sort ( $ needle , $ haystack );
print_r ( $ result );
结果将表示为有序数组,键为 Levenshtein 到针的距离:
Array
(
[1] => test
[2] => texas
[6] => random
)
如果到针的距离相同,则将创建嵌套数组:
$ needle = 'text' ;
$ haystack = array ( 'texa
【文件预览】:
levenshtein-array-sort-master
----composer.json(713B)
----tests()
--------VBartusevicius()
----LICENSE(18KB)
----src()
--------VBartusevicius()
----.gitignore(22B)
----phpunit.xml.dist(547B)
----README.md(865B)