From 0df6a2339b65139da586ba98492aae1f15843f9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E5=85=B4=E8=8C=82?= Date: Wed, 19 Sep 2018 15:14:34 +0800 Subject: [PATCH] Fix bug #2 --- ahocorasick.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ahocorasick.php b/ahocorasick.php index 0dcd7bf..cd3747c 100644 --- a/ahocorasick.php +++ b/ahocorasick.php @@ -95,7 +95,7 @@ public function search($haystack) { for ($i = 0; $i < strlen($haystack); ++$i) { $c = $haystack[$i]; - while(!isset($nodes[$n][$c]) && $n) { + while(!in_array($c, array_keys($nodes[$n]), true) && $n) { $n = $nodes[$n][1]; if ($n === null) die(); }