PHP code example of tianhe1986 / fatahocorasick
1. Go to this page and download the library: Download tianhe1986/fatahocorasick 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/ */
tianhe1986 / fatahocorasick example snippets
use FatAhoCorasick\FatAhoCorasick;
$ac = new FatAhoCorasick();
//add keyword, string or array
$ac->addKeyword(['art', 'cart']);
$ac->addKeyword('ted');
//compute info
$ac->compute(false); //not using next array
//$ac->compute(true); using next array
//search
$result = $ac->search('a carted mart lot one blue ted');