Find closest longitude and latitude in array?

后端 未结 4 1710
情深已故
情深已故 2020-12-12 23:04

I have a longitude and latitude as a string in PHP like below

49.648881
-103.575312

And I want to take that and look in an array of values

4条回答
  •  别那么骄傲
    2020-12-12 23:42

    There is no quick and easy way to do that. You have to iterate through all elements and calculate distance between them and starting point, save the result and repeat, saving the result only if it is lower then previous.

提交回复
热议问题