Skip to content
A Simple Fuzzy Search Package for PHP
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.gitignore
.styleci.yml
.travis.yml Fix StyleCI Dec 7, 2016
composer.json
phpunit.xml.dist Init Jul 7, 2015
readme.md Update Readme Mar 12, 2016

readme.md

Simple Fuzzy Search for PHP

StyleCI Build Status Latest Stable Version Total Downloads Latest Unstable Version License

About

A Simple Fuzzy Search component using Levenshtein Distance (LD) Algorithm and Longest Common Substring (LCS) Algorithm.

Requirement

  • PHP >= 5.4

Install

You can install and manage SimpleFuzzySearch by using Composer

composer require wataridori/simple-fuzzy-search

Or add wataridori/simple-fuzzy-search into the require section of your composer.json file then run composer update

Usage

$arrayData = [
    [
        'nickname' => 'thangtd90',
        'fullname' => 'Tran Duc Thang',
    ],
    [
        'nickname' => 'trongbs',
        'fullname' => 'Tran Ba Trong',
    ],
    [
        'nickname' => 'vigov5',
        'fullname' => 'Nguyen Anh Tien',
    ],
    [
        'nickname' => 'kienBG',
        'fullname' => 'Do Trung Kien',
    ],
    [
        'nickname' => 'vuong',
        'fullname' => 'Nguyen Van Vuong',
    ],
    [
        'nickname' => 'dainghia',
        'fullname' => 'Le Van Nghia',
    ],
    [
        'nickname' => 'tungctf',
        'fullname' => 'Nguyen Duc Tung',
    ],
];

// Find by both nickname and fullname
$sfs = new SimpleFuzzySearch($this->arrayData, ['nickname', 'fullname'], 'tung');

// This will return "Nguyen Duc Tung" and "Do Trung Kien"
$results = $sfs->search();

// This will return "Tran Duc Thang"
$results = $sfs->search('trn dc thsng');

Test

Just run phpunit to start test.

You can’t perform that action at this time.