I'm looking for a simple way to find matching portions of two strings in PHP (specifically in the context of a URI)
For example, consider the two strings:
What I need is to chop off the matching portion of these two strings from the second string, resulting in:
before appending the first string as a prefix, forming an absolute URI.
Is there some simple way (in PHP) to compare two arbitrary strings for matching substrings within them?
EDIT: as pointed out, I meant the longest matching substring common to both strings
This would be the answer. Ready-to-use PHP function.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki