forked from ph4r05/php_aho_corasick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test3.php
22 lines (16 loc) · 814 Bytes
/
test3.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
// initialize search , returns resourceID for search structure
$c = ahocorasick_init(array());
ahocorasick_add_patterns($c, array(array('key'=>'ab', 'value'=>'alfa')));
ahocorasick_add_patterns($c, array(array('key'=>'ac', 'value'=>'beta')));
ahocorasick_add_patterns($c, array(array('key'=>'ad', 'value'=>'gamma', 'aux'=>array(1))));
ahocorasick_add_patterns($c, array(array('key'=>'ae', 'value'=>'delta')));
ahocorasick_add_patterns($c, array(array('id'=>0, 'value'=>'zeta'),
array('key'=>'ag', 'value'=>'omega'),
array('value'=>'lfa')));
// perform search 1
$d1 = ahocorasick_match("alFABETA gamma zetaomegaalfa!", $c);
//unset($d1);
// deinitialize search structure (will free memory)
ahocorasick_deinit($c);
var_dump($d1);