PHP code example of ifcanduela / abbrev

1. Go to this page and download the library: Download ifcanduela/abbrev library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ifcanduela / abbrev example snippets


use ifcanduela\abbrev\Abbrev;

$abbrev = new Abbrev(
        'foo',
        'bar',
        ['baz', 'foobar', ['barbaz']],
    );

$abbrev = new Abbrev(['ape', 'aperture', 'apprentice'], 'albino', 'append');

$match = $abbrev->match('ap'); // there is not unambiguous match
// => false

$match = $abbrev->match('al'); // there is only one possible match
// => "albino"

$abbrev = new Abbrev(['ape', 'aperture', 'apprentice'], 'albino', 'append');

$suggestions = $abbrev->suggest('app');
// append
// apprentice

$abbrev = new Abbrev(['ape', 'aperture', 'apprentice'], 'albino', 'append');

$suggestions = $abbrev->abbreviate();
// [
//   'alb'        => 'albino',
//   'albi'       => 'albino',
//   'albin'      => 'albino',
//   'albino'     => 'albino',
//   'ape'        => 'ape',
//   'aper'       => 'aperture',
//   'apert'      => 'aperture',
//   'apertu'     => 'aperture',
//   'apertur'    => 'aperture',
//   'aperture'   => 'aperture',
//   'appe'       => 'append',
//   'appen'      => 'append',
//   'append'     => 'append',
//   'appr'       => 'apprentice',
//   'appre'      => 'apprentice',
//   'appren'     => 'apprentice',
//   'apprent'    => 'apprentice',
//   'apprenti'   => 'apprentice',
//   'apprentic'  => 'apprentice',
//   'apprentice' => 'apprentice',
// ]