esyede / fuzzy

Fuzzy search using Levenshtein Distance (LD) and Longest Common Substring (LCS) algorithm.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fuzzy

Fuzzy search using Levenshtein Distance (LD) and Longest Common Substring (LCS) algorithm (single file, no dependencies)

Requirements

  • PHP 5.4 or newer

Installation

Download the file from release page and drop to your project. That's it.

Usage example

require 'Fuzzy.php';

$data = [
  ['name' => 'Halima Nasyidah', 'address' => 'Jln. Wahidin Sudirohusodo No. 483'],
  ['name' => 'Tiara Novitasari', 'address' => 'Gg. Kenanga No. 86'],
  ['name' => 'Irwan Balapati Nugroho', 'address' => 'Perum. Jamika No. 952'],
  ['name' => 'Dimas Marwata Napitupulu', 'address' => 'Kpg. Sijangkir No. 792']
];

$fuzzy = new Esyede\Fuzzy($data);

$keyword = 'Arah';
$attributes = 'name';

$results = $fuzzy->search($keyword, $attributes);
print_r($results);

$keyword = 'Na';
$attributes = ['name', 'address'];

$results = $fuzzy->search($keyword, $attributes);
print_r($results);

That's pretty much it. Thank you for stopping by!

License

This library is licensed under the MIT License

About

Fuzzy search using Levenshtein Distance (LD) and Longest Common Substring (LCS) algorithm.

License:MIT License


Languages

Language:PHP 100.0%