PHP: how to do array_search with 40% Partial Matching -
i using php partial matching. problem there huge list of matching available every time. want limit it. shows partial match when matches 40 % (means 4 characters out of 10).
try this:
function fuzzymatch ($source, $term, $percentrequired){ $matches = array_filter($source, function($test) use ($term, $percentrequired){ $matchper = null; similar_text($term, $test, $matchper); return $matchper >= $percentrequired; }); return $matches; }
this take array or terms, term want match against , % required match , return array matching values.
Comments
Post a Comment