Put the names in an array, loop through each name, compare it to the other names from the current position to the end.
I'd strip out common words and see how many distinctive words the two names have in common, something like this:
<?php
function try2 ($name1, $name2, $cutoff) {
$common_words = array("/golf|course|club/i");
$pattern = "/" . join ("|", preg_split("/\s+/", trim (preg_replace ($common_words, ' ', $name1)))) . "/i";
if ( preg_match_all ($pattern, $name2, $matches) >= $cutoff ) {
echo $name1 . ' <- match? -> ' . $name2 . '<p>';
}
else {
echo $name1 . ' <- not even close -> ' . $name2 . '<p>';
}
}
try2( "pebble beach golf course", "Course at Pebble Beach", 1);
try2( "Herbies golf course", "Course at Pebble Beach", 1);
?>