s9e/longest-common-substring

Longest common substring generator

1.0.0 2022-09-14 22:10 UTC

This package is auto-updated.

Last update: 2024-10-29 18:32:42 UTC


README

s9e\LongestCommonSubstring takes a list of strings and returns a single string that is contained in all of the given input. The implementation is designed for sets where the shortest input string is 10-20 bytes long at most, and where a common substring is not guaranteed to exist. For large input, you'll want to use a different implementation.

Usage

$lcs = new s9e\LongestCommonSubstring\LongestCommonSubstring;
var_dump($lcs->get(['abcdxyz', 'xyzabcd']));
string(4) "abcd"
$lcs = new s9e\LongestCommonSubstring\LongestCommonSubstring;
var_dump($lcs->get(['foo', 'bar']));
string(0) ""