Matcher – PHP Autocomplete https://phpautocomplete.com The Ultimate PHP Dropdown Tue, 11 Mar 2014 04:59:38 +0000 en-US hourly 1 https://wordpress.org/?v=7.0.4 set_matcher() https://phpautocomplete.com/docs/set_matcher/ Fri, 14 Feb 2014 17:48:59 +0000 http://phpautocomplete.com/?p=140 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>
]]>