set_matcher()

Use this method to override how string match is conducted.¬†By default, the PHP Autocomplete matches searched term anywhere in options. In most case, you don’t need to call this method. Keep in mind that only a single matcher can be used.

Signature:

public function set_matcher($js_cust_matcher)

Parameters:

  • $js_cust_matcher:¬†JavaScript function to set custom matcher

Example that demos case sensitive search and must search from the beginning of the string

<?php
...
// only a single matcher can be used at a time
$pac->set_matcher('search_casesensitive_and_beginning');
...
?>
<script>
function search_casesensitive_and_startbeginning(term, text){
    return (text.indexOf(term)>=0)
            &&
            text.toUpperCase().indexOf(term.toUpperCase())==0;
}
</script>

No related content found.

Tags: