开发者

remove duplicate addresses from google maps api results

I am using the Google Maps API to allow users to enter their location and return results based on their location. However, when I enter some addresses in Australia I am getting duplicates such as:

Asquith, New South Wales 2077, Australia

Asquith New South Wales, Australia

and

Wollstonecraft, Sydney New South Wales开发者_如何学C 2065, Australia

Wollstonecraft New South Wales 2065, Australia

Currently, I provide an option for a member to choose between the results if there are duplicates, but I feel that with some clever PHP i can duplicate this step. I'm not very good with preg_replace (if that is the solution), and hope someone has a solution. Basically, I want a function to compare two (or more) addresses and return true if they are the same and false if they are different addresses.

Notice also in the second example, Sydney has been added so this needs to be factored into whatever solution anyone could kindly offer.

I think most duplicate results sets will be generally in the same format, and should be able to tweak the function if I notice other exceptions.

Thanks so much for any help that can be provided.


You can use the function similar_text to determine how similar two strings are.

Example:


<?php
similar_text("Wollstonecraft, Sydney New South Wales 2065, Australia", "Wollstonecraft New South Wales 2065, Australia", $p);
echo "Percent: $p%";
?>

This would produce : Percent: 92%

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜