2017 © Pedro Peláez
 

library kmp

KMP string search algorithm

image

algo/kmp

KMP string search algorithm

  • Saturday, April 9, 2016
  • by c9s
  • Repository
  • 2 Watchers
  • 6 Stars
  • 3 Installations
  • C
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

KMP string match algorithm

Build Status, (*1)

Requirement

  • PHP ^5.3

Install

phpize 
make
make install

Usage

kmp_search(string haystack, string needle)

Return value: (int) This function returns -1 if needle is not found in haystack., (*2)

$pos = kmp_search("zjifeoabcabcjiefjie", "abcabc");

kmp_prefix(string needle)

Return value: (resource) This function returns a resource of pre-computed prefixes array. The returned resource can be reused when there are multiple haystacks to be searched., (*3)

$prefix = kmp_prefix("abcabc");
$pos = kmp_search_prefix("zjifeoabcabcjiefjie", $prefix);

References

  • KMP algorithm http://www-igm.univ-mlv.fr/~lecroq/string/node8.html
  • MP algorithm http://www-igm.univ-mlv.fr/~lecroq/string/node7.html

License

Released under MIT license, (*4)

The Versions

09/04 2016

dev-master

9999999-dev http://github.com/c9s/phpkmp

KMP string search algorithm

  Sources   Download

MIT

The Requires

  • php >=5.3.0