s9e / longest-common-substring
Longest common substring generator
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/s9e/longest-common-substring
Requires
- php: >=8.0
Requires (Dev)
This package is auto-updated.
Last update: 2025-09-29 02:58:18 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) ""