Distance between two points


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. //$lat1 = 46.2341938036161;
  2. //$lon1 = -63.124778021257015;
  3. //$lat2 = 46.4141938036161;
  4. //$lon2 = -63.118571124705284;
  5.  
  6. function distance($lat1,$lon1,$lat2,$lon2) {
  7. return (3958*3.1415926*sqrt(($lat2-$lat1)*($lat2-$lat1) + cos($lat2/57.29578)*cos($lat1/57.29578)*($lon2-$lon1)*($lon2-$lon1))/180);
  8. }

URL: http://www.barattalo.it

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.