similar_text を使用して比較できます。唯一の問題は、比較可能性係数が恣意的に見えることです。
<?php
$array1 = array("http://example.com/abc","http://google.com/xyz","http://yahoo.com/abc", "http://stackoverflow.com/mnr");
$array2 = array("http://example.com/xyz","http://w3schools.com/xyz","http://stackoverflow.com/abc");
print_r($array1);
print_r($array2);
echo "\n";
foreach ($array1 as $slice)
{
foreach ($array2 as $slice2)
{
echo 'Comparing '.$slice.' to '.$slice2.' gives comparability of '.similar_text($slice,$slice2)."\n";
if (similar_text($slice,$slice2) > 18)
{
echo $slice.' ____is similar to___ '.$slice2."\n";
}
}
}
?>
出力:
Comparing http://example.com/abc to http://example.com/xyz gives comparability of 19
http://example.com/abc ____is similar to___ http://example.com/xyz
Comparing http://example.com/abc to http://w3schools.com/xyz gives comparability of 13
Comparing http://example.com/abc to http://stackoverflow.com/abc gives comparability of 17
Comparing http://google.com/xyz to http://example.com/xyz gives comparability of 17
Comparing http://google.com/xyz to http://w3schools.com/xyz gives comparability of 18
Comparing http://google.com/xyz to http://stackoverflow.com/abc gives comparability of 14
Comparing http://yahoo.com/abc to http://example.com/xyz gives comparability of 13
Comparing http://yahoo.com/abc to http://w3schools.com/xyz gives comparability of 15
Comparing http://yahoo.com/abc to http://stackoverflow.com/abc gives comparability of 18
Comparing http://stackoverflow.com/mnr to http://example.com/xyz gives comparability of 14
Comparing http://stackoverflow.com/mnr to http://w3schools.com/xyz gives comparability of 16
Comparing http://stackoverflow.com/mnr to http://stackoverflow.com/abc gives comparability of 25
http://stackoverflow.com/mnr ____is similar to___ http://stackoverflow.com/abc
そのため、一致したものを配列に入れて後で出力します。