v-bartusevicius/levenshtein-array-sort 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

v-bartusevicius/levenshtein-array-sort

Composer 安装命令:

composer require v-bartusevicius/levenshtein-array-sort

包简介

Sorts haystack with strings by Levenshtein distance to needle

README 文档

README

Sorts given array of strings by Levenshtein distance.

Simply use:

$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:

Array
(
    [1] => test
    [2] => texas
    [6] => random
)

In case there are same distances to needle, the nested array will be created:

$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
)

#Installation: composer require v-bartusevicius/levenshtein-array-sort

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2015-03-07