Remove equal part of two strings
<p>In PHP, I have two paths on a server that both have a matching part. I'd like to join them, but delete the part that is equal.</p>

<p>EXAMPLE:</p>

<p>Path #1:
/home7/username/public_html/<strong>dir/anotherdir/wp-content/uploads</strong></p>

<p>Path #2:
<strong>/dir/anotherdir/wp-content/uploads</strong>/2011/09/image.jpg</p>

<p>You see the part <strong>/dir/anotherdir/wp-content/uploads</strong> is the same in both strings, but when I simply join them I would have some directories twice.</p>

<p>The output I need is this:
<strong>/home7/username/public_html/dir/anotherdir/wp-content/uploads/2011/09/image.jpg</strong></p>

<p>Since the dirs can change on different servers I need a dynamic solution that detects the matching part from #2 and removes it on #1 so I can trail #2 right after #1 :)</p>
