I have two strings:
$a = '/srv/http/projects/name';
$b = '/projects/name/some/dir';
And I would like to get a merged string with not repeated common part:
$c = '/srv/http/projects/name/some/dir';
Is there any effective way to get it ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Nothing that I know of out-of-the-box.
but this should do it:EDIT: Had an OBO, updated.
UPDATE: That was not the solution, strpos() is matching portions of text anywhere in the left path, should compare against tail.
Here is the correct implementation for my approach: