Skip to content


Fuzzy array search using PHP.

Update on the fuzzy string search with PHP article. I’ve seen a few searches from Google of people try to find out how to do a fuzzy / approximate string search against array values, well today I have the class for doing just that.

The class is simple to use.
It also does multi-level searching, so embed the arrays as far as you want.

  1. <?php
  2.     include "FuzzyArraySearch.php";
  3.     $search = new ArraySearch("test", array("pest");
  4.     $search->Search();
  5.     $search->GetResults();
  6. ?>

As a quick example, the following array.

  1. array("rest", "string", "blah", array("hello", array("again", array(array(array("reset"), "rest"))), "pest"))

Output the following when var_dumping the results.

  1. array
  2.   0 => string 'rest at Base->0' (length=15)
  3.   1 => string 'reset at Base->3->1->1->0->0->0' (length=31)
  4.   2 => string 'rest at Base->3->1->1->0->0->1' (length=30)
  5.   3 => string 'pest at Base->3->1->2' (length=21)

Quite simple. Anyhow, that is all I wanted to post, the download link is just below.

Fuzzy Array Search (140)

Posted in Uncategorized.

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.