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.
-
<?php
-
include "FuzzyArraySearch.php";
-
$search = new ArraySearch("test", array("pest");
-
$search->Search();
-
$search->GetResults();
-
?>
As a quick example, the following array.
-
array("rest", "string", "blah", array("hello", array("again", array(array(array("reset"), "rest"))), "pest"))
Output the following when var_dumping the results.
-
array
-
0 => string 'rest at Base->0' (length=15)
-
1 => string 'reset at Base->3->1->1->0->0->0' (length=31)
-
2 => string 'rest at Base->3->1->1->0->0->1' (length=30)
-
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.
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.